免责声明:本资源并未取得原始权利人的授权,不可商用,仅可用于学习分析底层代码,CSS等,禁止用于商业行为。如因擅自商用引起的相关纠纷及法律责任,由使用人全部承担。支持正版,人人有责,请于下载后24小时内删除,谢谢支持!
如果蓝奏云下载失效请更换最新链接:nnym.lanzouh.com//xxxx 【x改成h】
图标说明
Dashicons 是 WordPress 从 3.8 开始的官方图标字体,Dashicons 项目接受图标其他请求,项目由WordPress官方管理!
图标使用
WordPress 使用
WordPress 使用可以使用“register_post_type()”和添加管理菜单项“add_menu_page()”,它们都具有设置图标的选项。要显示当前图标,您应该传入“dashicons-align-full-width”
演示例子
在register_post_type(),设置menu_icon在参数数组中。
<?php/*** Register the Product post type with a Dashicon.** @see register_post_type()*/function wpdocs_create_post_type() {register_post_type( 'acme_product',array('labels' => array('name' => __( 'Products', 'textdomain' ),'singular_name' => __( 'Product', 'textdomain' )),'public' => true,'has_archive' => true,'menu_icon' => 'dashicons-products',));}add_action( 'init', 'wpdocs_create_post_type', 0 );<?php /** * Register the Product post type with a Dashicon. * * @see register_post_type() */ function wpdocs_create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products', 'textdomain' ), 'singular_name' => __( 'Product', 'textdomain' ) ), 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-products', ) ); } add_action( 'init', 'wpdocs_create_post_type', 0 );<?php /** * Register the Product post type with a Dashicon. * * @see register_post_type() */ function wpdocs_create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products', 'textdomain' ), 'singular_name' => __( 'Product', 'textdomain' ) ), 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-products', ) ); } add_action( 'init', 'wpdocs_create_post_type', 0 );
该函数add_menu_page()在图标 URL 的回调函数之后接受一个参数,它也可以接受一个 dashicons 类。
<?php/*** Register a menu page with a Dashicon.** @see add_menu_page()*/function wpdocs_add_my_custom_menu() {// Add an item to the menu.add_menu_page(__( 'My Page', 'textdomain' ),__( 'My Title', 'textdomain' ),'manage_options','my-page','my_admin_page_function','dashicons-admin-media');}<?php /** * Register a menu page with a Dashicon. * * @see add_menu_page() */ function wpdocs_add_my_custom_menu() { // Add an item to the menu. add_menu_page( __( 'My Page', 'textdomain' ), __( 'My Title', 'textdomain' ), 'manage_options', 'my-page', 'my_admin_page_function', 'dashicons-admin-media' ); }<?php /** * Register a menu page with a Dashicon. * * @see add_menu_page() */ function wpdocs_add_my_custom_menu() { // Add an item to the menu. add_menu_page( __( 'My Page', 'textdomain' ), __( 'My Title', 'textdomain' ), 'manage_options', 'my-page', 'my_admin_page_function', 'dashicons-admin-media' ); }
CSS/HTML 用法
如果您想在菜单之外的管理员中使用破折号,可以使用两个帮助程序类。这些是dashicons-beforeand dashicons,它们可以被认为是设置 dashicons(因为你仍然需要你的 icon 的类)。
例子
使用类将图标添加到标题中dashicons-before。这可以直接添加到带有文本的元素中。
<h2 class="dashicons-before dashicons-smiley">你的标题</h2><h2 class="dashicons-before dashicons-smiley">你的标题</h2><h2 class="dashicons-before dashicons-smiley">你的标题</h2>
使用类将图标添加到标题中dashicons。请注意,在这里,您需要专门为图标添加额外的标记。
<h2><span class="dashicons dashicons-smiley"></span>你的标题</h2><h2><span class="dashicons dashicons-smiley"></span>你的标题</h2><h2><span class="dashicons dashicons-smiley"></span>你的标题</h2>
块使用
块编辑器支持将短划线用作块图标和它自己的组件。
例子
将图标添加到块中。该registerBlockType函数接受一个参数“icon”,它接受一个破折号的名称。提供的示例被截断。请参阅块编辑器手册中的完整示例。
registerBlockType( 'gutenberg-examples/example-01-basic-esnext', {apiVersion: 2,title: 'Example: Basic (esnext)',icon: 'universal-access-alt',category: 'design',example: {},edit() {},save() {},} );registerBlockType( 'gutenberg-examples/example-01-basic-esnext', { apiVersion: 2, title: 'Example: Basic (esnext)', icon: 'universal-access-alt', category: 'design', example: {}, edit() {}, save() {}, } );registerBlockType( 'gutenberg-examples/example-01-basic-esnext', { apiVersion: 2, title: 'Example: Basic (esnext)', icon: 'universal-access-alt', category: 'design', example: {}, edit() {}, save() {}, } );
使用图标作为组件。有一个专用Dashicon
组件可用。请参阅块编辑器手册中的相关文档。
从“@wordpress/components”导入 { Dashicon };const MyDashicon = () => (<div><Dashicon icon="admin-home" /><Dashicon icon="products" /><Dashicon icon="wordpress" /></div>);从“@wordpress/components”导入 { Dashicon }; const MyDashicon = () => ( <div> <Dashicon icon="admin-home" /> <Dashicon icon="products" /> <Dashicon icon="wordpress" /> </div> );从“@wordpress/components”导入 { Dashicon }; const MyDashicon = () => ( <div> <Dashicon icon="admin-home" /> <Dashicon icon="products" /> <Dashicon icon="wordpress" /> </div> );
Photoshop 使用
为 Photoshop 模型使用 .OTF 版本的字体,网络字体版本将不起作用。要获得最准确的结果,请选择“Sharp”字体平滑。

感谢您的来访,获取更多精彩文章请收藏本站。

MianzeShengming
1、本站提供的源码不拥有任何权利,其版权归原著者拥有。
2、保证站内提供的所有可下载资源(软件等等)都是按“原样”提供,本站未做过任何大规则的修改;但本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。
3、牛牛源码库平台服务中的任何信息或材料的删除、存储失败、错误提供或未及时提供不承担任何责任。
4、牛牛源码库平台其许可方不对通过牛牛源码库网主题服务得到的或在其上刊登广告所推介的产品或服务、通过由牛牛源码库平台服务提供的任何链接而得到的产品或服务,以及通过在牛牛源码库网平台服务中所提供的任何链接而得到的任何信息或建议做任何担保,对因通过服务下载或访问网上的任何信息或材料而导致的任何伤害不承担任何责任。
5、牛牛源码库平台服务包含的下载资源信息内的所有内容并不反映亦不代表任何牛牛源码库平台之意见。
6、牛牛源码库平台服务包含的下载资源信息内的所有内容并不反映亦不代表任何牛牛源码库平台之意见。牛牛源码库平台作为模板共享网络服务提供者,对非法转载,盗版行为的发生不具备充分的监控能力,但是当版权拥有者提出侵权指控并出示充分的版权证明材料时,牛牛源码库网平台负有移除盗版和非法转载作品以及停止继续传播的义务。
7、牛牛源码库平台对他人在网站上实施的此类侵权行为不承担法律责任,侵权的法律责任概由会员本人承担,向牛牛源码库发布作品的作者视为同意牛牛源码库就前款情况采取的相应措施。
8、牛牛源码库平台在满足前款条件下采取移除等相应措施后不为此向原发布人承担违约责任或其他法律责任,包括不承担因侵权指控不成立而给原发布人带来损害的赔偿责任。
9、本网站所有源码、模板、视频、软件和资料均为软件作者提供和站长从互联网收集整理而来,仅供学习和研究使用,请勿用于其他用途。如果版权拥有者发现自己作品被侵权,请及时向牛牛源码库提出权利通知,将身份证明、权属证明、具体链接(URL)及详细侵权情况证明发往(邮箱:1138006142@qq.com)指出,牛牛源码库平台在收到上述法律文件后,在7个工作日内移除相关涉嫌侵权的内容。
暂无评论内容