ladda添加自定义css_将自定义CSS添加到WordPress Admin

本文介绍了如何在WordPress管理界面中添加自定义CSS,以提高代码样例的可读性和识别性,包括创建CSS文件并将它们整合到WordPress Admin中。
摘要由CSDN通过智能技术生成

ladda添加自定义css

Believe it or not, I spend an awful lot of time going through my blog's comments and correcting spelling issues, code formatting, etc.; yes, even the comments from way back to 2007.  It's mostly for quality control purposes and ease of reading for my readers, especially the code comments.

信不信由你,我花了很多时间浏览博客的评论并纠正拼写问题,代码格式等。 是的,甚至是从2007年以来的注释。它主要是出于质量控制的目的,并且使我的读者易于阅读,尤其是代码注释。

One gripe I have with WordPress' admin section is that it's difficult to spot <pre> tag contents, especially code samples that are only one line.  It made me think: "wouldn't it be awesome if I could add my own styles to the WordPress admin interface?"  If it's awesome, I want to do it, so here's how you can add your own custom styles to WordPress admin!

我对WordPress的管理部分有一个困扰,那就是很难发现<pre>标签的内容,尤其是仅一行的代码示例。 这让我想到:“如果我可以将自己的样式添加到WordPress管理界面中,那会很棒吗?” 如果真棒,我想这样做,所以这是您可以向WordPress管理员添加自定义样式的方法!

步骤1:建立CSS档案 (Step 1:  Create Your CSS File)

You can place the CSS file wherever you'd like; I've chosen to place the CSS file within my theme.  My admin CSS file looks like:

您可以将CSS文件放置在任意位置。 我选择将CSS文件放入主题中。 我的管理CSS文件如下所示:


.wp-admin .comment pre {
  background: pink; /* they forgot the language! */
  padding: 6px 10px;
  font-size: 16px;
  border: 1px solid #ccc;
}

.wp-admin .comment pre[class] {
  background: #fff; /* language (likely) there */
}



The CSS above makes <pre> tags more visible.  It also will make any PRE element without a class more apparent, teling me I need to fix it by adding the language as a className.

上面CSS使<pre>标签更加可见。 它也会使没有class任何PRE元素更加明显,告诉我我需要通过将语言添加为className来修复它。

步骤2:在functions.php中将CSS添加到WordPress Admin (Step 2:  Add Your CSS to WordPress Admin in functions.php)

WordPress uses an add_action type of admin_enqueue_scripts for adding stylesheets anywhere within WordPress:

WordPress使用admin_enqueue_scriptsadd_action类型在WordPress中的任意位置添加样式表:


// Update CSS within in Admin
function admin_style() {
  wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');
}
add_action('admin_enqueue_scripts', 'admin_style');


get_template_directory_uri provides the path to your current theme, you simply need to add the filename to the end of the path.

get_template_directory_uri提供当前主题的路径,您只需要在路径末尾添加文件名即可。

If you get annoyed with WordPress Admin styles like myself, feel free to jump in and change them.  My update was very simple; if you want to completely overhaul the WordPress theme so your clients think they're getting a completely customized system, feel free to do so!

如果您对像我这样的WordPress管理员样式感到恼火,请随时加入并进行更改。 我的更新非常简单; 如果您想彻底修改WordPress主题,以便您的客户认为他们正在获得完全自定义的系统,请随时这样做!

翻译自: https://davidwalsh.name/add-custom-css-wordpress-admin

ladda添加自定义css

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值