Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
css在rails中的放置问题(使用引导)_Css_Ruby On Rails_Twitter Bootstrap - Fatal编程技术网

css在rails中的放置问题(使用引导)

css在rails中的放置问题(使用引导),css,ruby-on-rails,twitter-bootstrap,Css,Ruby On Rails,Twitter Bootstrap,假设在样式表/myFilename.css.scss中有以下内容: ... .carousel-control.left, .carousel-control.right { background-image: none; } ... 除非我将其修改为: ... .carousel-control.left, .carousel-control.right { background-image: none !important; } ... 但是,如果我没有将css放

假设在样式表/myFilename.css.scss中有以下内容:

...

.carousel-control.left, .carousel-control.right {
    background-image: none;
}

...
除非我将其修改为:

...

.carousel-control.left, .carousel-control.right {
    background-image: none !important;
}

...
但是,如果我没有将css放在stylesheets文件夹中,而是将它直接放在myfile.html.erb中,那么我就不需要
!重要信息
。我如何解决这个问题


我假设这和样式表中css的排序/组合有关,但我不确定。如果有人能透露一些信息,那就太好了

您应该在主样式表之后添加样式表/myFilename.css.scss文件。 假设您的所有css样式都来自styleshees/style.css

现在,您应该在索引或关联头文件中写入(styleshees/myFilename.css.scss)它(styleshees/style.css)

例如

<link rel="stylesheet" type="text/css" href="/styleshees/style.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/myFilename.css.scss">

不是


这是因为CSS有一个它遵循的级联层次结构。就你而言:

  • 内联样式
  • 内部样式表
  • 外部样式表
  • 内部样式表的优先级高于外部样式表,因此,如果直接在html中声明它,就不需要!重要信息覆盖导致此冲突的任何其他外部样式表

    进一步阅读css层次结构和特定性:

    如果你需要一个!重要信息在外部样式表中,这意味着您在其他地方存在css冲突。在选择器中更具体总是比使用更好!重要的是,您可以这样做:

    /*Use an ID in your html*/
    #my_id .carousel-control.left, #my_id .carousel-control.right {
       background-image: none;
    }
    

    你需要使规则更加具体@dfsq太棒了。非常感谢。
    /*Use an ID in your html*/
    #my_id .carousel-control.left, #my_id .carousel-control.right {
       background-image: none;
    }