Html Rails-如何确保我的样式优先于引导?
我相信这是一个非常简单的问题,但我找不到一个直接的答案,所以我想我会在这里问 我正在使用Bootstrap构建一个站点,不过我希望我的自定义样式优先于Bootstrap 我想这可能很简单,只需在我的Html Rails-如何确保我的样式优先于引导?,html,css,ruby-on-rails,twitter-bootstrap,asset-pipeline,Html,Css,Ruby On Rails,Twitter Bootstrap,Asset Pipeline,我相信这是一个非常简单的问题,但我找不到一个直接的答案,所以我想我会在这里问 我正在使用Bootstrap构建一个站点,不过我希望我的自定义样式优先于Bootstrap 我想这可能很简单,只需在我的应用程序.css.scss文件中调整顺序,但我的修补还没有找到解决方案 目前该文件如下所示: /* * This is a manifest file that'll be compiled into application.css, which will include all the files
应用程序.css.scss
文件中调整顺序,但我的修补还没有找到解决方案
目前该文件如下所示:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
我刚刚开始构建这个站点,有两个引导网格列,其中一个我想删除其中的填充。另一方面,我添加了背景图像和高度,没有问题。以下代码来自home.css.scss
:
.col-md-4 {
background: url('http://i.imgur.com/xxxxxxxxxxxx.jpg');
height: 1000px;
} //both of which work
.col-md-8 {
padding: 0px 0px 0px 0px;
} //which is overridden by Bootstrap's default styling
正如我所说的,希望这是一个真正简单的解决方案,不会花费太多的精力来回答。谢谢你的帮助!史蒂夫。你可以利用
!重要信息
。
它说什么;“这很重要,忽略后续规则和任何常见的特殊性问题,应用此规则!”
p{
颜色:红色!重要;
}
#东西{
颜色:绿色;
}
将是红色。
使用@BroiSatse的伟大链接得出了答案:
由于Bootstrap和my code都引用了类.col-md-8
,Bootstrap的样式由于其在级联中的位置而优先
通过移动
@import“引导链轮”@导入“引导”
从application.css.scss
到home.css.scss
的顶部,我的样式优先。一切都正常运转!谢谢大家的帮助。使用!重要的< /代码>是有风险的,它应该只在没有其他方法可用时使用。@ GnasHalunkHe——使用<代码> Goto 也是C++中的一种解决方法。放置是一种不好的做法!重要信息
-这意味着开发人员不了解CSS的特殊性,并试图从CSS中去掉C。层叠很美,不要扼杀它。一个主题的好读物:很棒的读物,我已经用它找到了我问题的答案。当类匹配时,由于其在级联中的位置,引导优先。通过移动@import“引导链轮”@导入“引导”代码>到home.css.scss
my styles的顶部,然后优先。非常感谢@Broisasze。