【问题标题】:Issue overriding bootstrap CSS问题覆盖引导 CSS
【发布时间】:2016-12-16 21:12:06
【问题描述】:

我在 WordPress 中设置了一个 child theme 并将 /style.css/inc/css/bootstrap.min.css 加入队列,因为这是我从父主题修改的 2 个样式表:

function my_theme_styles() {
wp_enqueue_style( 'child', get_stylesheet_directory_uri() . '/style.css', array(), '1.0' );
wp_enqueue_style( 'child-bootstrap', get_stylesheet_directory_uri() . '/inc/css/bootstrap.min.css', array(), '1.0' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_styles', 99 );

看起来,当我将修改放入 bootstrap.min.css 文件时,它仍然从父 bootstrap.min.css 加载数据。

我尝试将 !important 添加到末尾,甚至将 CSS 添加到 footer.php 文件中以查看是否会覆盖它,但无济于事。

任何建议将不胜感激。

谢谢

已解决:我有点像木偶。在子 bootstrap.min.css 文件中,我将 background-color: none 放在元素上,而在父 bootstrap.min.css 中它具有背景颜色。我必须把透明而不是没有。

【问题讨论】:

  • 我以前也遇到过这样的问题,而且大部分时间它与您的机器或服务器中的缓存有关,您是否尝试过清除所有可能的缓存并验证您的更改是否显示?你可以阅读更多关于它here
  • @ArmandoBracho 感谢您的回复。我刚刚清除了浏览器缓存,刷新了,还是没有乐趣。

标签: php css wordpress twitter-bootstrap


【解决方案1】:

尽管它已经解决了,但我会在这里留下一个建议:在这种情况下,更好的解决方案是将父 CSS 文件出列

wp_dequeue_style( $handle );

OP 解决它的方式是可行的,但是将文件出列会导致性能稍好:)

【讨论】:

    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 2017-09-24
    • 2018-02-11
    • 2022-08-18
    • 2014-09-22
    • 2014-05-06
    • 1970-01-01
    相关资源
    最近更新 更多