html - style.css 在 Bootstrap 之前被包含

标签 html css wordpress twitter-bootstrap w3-total-cache

我正在尝试用我的 style.css(默认放置在我的 wordpress 主题文件夹中)覆盖 bootstrap。所以这是我的 functions.php 中的代码,用于使 Bootstrap cdn 和我的 css 排队:

function bootstrap() { 
wp_enqueue_style( 'bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css' ); 
wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js',  array('jquery') );

}
add_action('wp_enqueue_scripts', 'bootstrap');

function maincss() {
wp_enqueue_style( 'maincss', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'maincss');

这是我的头在我的谷歌检查器中的样子:

<link rel="stylesheet" id="maincss-css" href="http://bootstraptest.co.nf/wp-content/themes/HipsterTheme/style.css?ver=1.0.0" type="text/css" media="screen">

<link rel="stylesheet" id="bootstrap-css-css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css?ver=4.2.3" type="text/css" media="all">

我是 wordpress 的新手所以对我好一点:P

最佳答案

根据文档wp_enqueue_style ,您应该使用 $deps 参数声明 ma​​incss 的依赖项,如下所示:

wp_enqueue_style( 'maincss', get_template_directory_uri() . '/style.css',array('bootstrap-css') );

关于html - style.css 在 Bootstrap 之前被包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31795191/

相关文章:

html - 如何在同一行添加一些东西?

html - 似乎 IE 动画/处理我的 loading.gif 即使我设置了显示 :none?

javascript - 侧面导航栏在切换时更改页面内容的对齐方式

html - 有没有办法让鼠标完全忽略 html 元素?

html - CSS 右侧边栏 100% 高度不起作用

javascript - Android WebView JavaScript onClick 错误

php - 如何在 Wordpress API Post 中包含 META 字段?

html - Thymeleaf 在使用 Spring MVC @PathVariable 时无法解析静态资源

php - 自定义 WooCommerce 运输方式和距离费率值问题

css - 在 wordpress 的 php 文件中查找标签