【发布时间】:2015-02-07 00:19:30
【问题描述】:
更新:我的插件 css 在管理区域中不起作用。以下适用于我的网站供公众查看,但不适用于我正在构建的管理页面。
原始问题: 我正在尝试使 html 文本“使这个红色”,红色! 我有一个插件已添加到我的 Wordpress 插件文件夹中。在名为“plugin.php”的文件中的“bio-plugin”文件夹中,我有以下代码:
function register_bio_style(){
wp_register_style('bio-style',plugins_url('css/bio-style.css',__FILE__), false, '1.0.0', 'all');
}
add_action('init','register_bio_style');
function enqueue_bio_style(){
wp_enqueue_style( 'bio-style' );
}
add_action('wp_enqueue_scripts', 'enqueue_bio_style');
然后我有这个 html 工作:
<div class='bio_btn'>Make this text red</div>
然后我将 bio-style.css 放在一个名为 css 的文件夹中,该文件夹与 plugin.php 位于同一目录中
bio-style.css 代码为:
.bio_btn{
color: red;
background: black;
}
“Make this red”这句话出现在(管理)页面上,但它是黑色的。
【问题讨论】:
-
检查
bio-style.css是否正确链接 -
用 firebug 检查 css 和 class 调用是否正确?
-
尝试将其更改为
../css/bio-style.css或/css/bio-style.css -
我在页面源代码中找不到 bio-style.css 链接?
-
../css 和 /css 都不起作用