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_scripts
的add_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主题,以便您的客户认为他们正在获得完全自定义的系统,请随时这样做!
ladda添加自定义css