简体   繁体   English

样式表中的CSS规则,但不适用于浏览器

[英]css rule in stylesheet but not applied in browser

I'm making a grid in html: 我正在用html制作网格:

  *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box sizing: border-box; } .mygrid { margin: 0 0 20px 0; } &:after { content: ""; display: table; clear: both; } [class*='col-'] { float: left; padding-right: 20px; } .grid &:last-of-type { padding-right: 0; } .col-1-2 { width: 33.3%; } .col-2-3 { width: 66.6%; } .content { background-color: #8AB9FF; padding: 20px; } 
 <div class="mygrid"> <div class="col-1-2"> <div class="content"> <p>Text text text</p> </div> </div> <div class="col-2-3"> <div class="content"> <p>Text text text</p> </div> </div> </div> 

All changes apply on document except last rule on .content . 所有更改均适用于文档,但.content最后一条规则除外。 When I fire up document in browsers (chrome, mozilla, ie) and inspect element I can't see the color rule, but can see the other rules created. 当我在浏览器(chrome,mozilla等)中启动文档并检查元素时,我看不到颜色规则,但可以看到创建的其他规则。

As can i see, the boxes are blue. 如我所见,盒子是蓝色的。 Maybe there are more rules, that no shown here and interfere with your intent. 也许还有更多规则,此处未显示这些规则,并且会干扰您的意图。 But if you don't see the rule on the debugger, could be a simple syntax error in the production document. 但是,如果您在调试器上看不到规则,则可能是生产文档中的简单语法错误。 Not in this example. 在这个例子中没有。

EDIT: 编辑:

You should "inspect element" and lookup .content rule. 您应该“检查元素”并查找.content规则。 If inside you see something like this background-color: #8AB9FF; 如果在内部,您看到的是这样的 背景色:#8AB9FF; then another rule is overriding. 那么另一个规则是压倒一切。 Try this. 尝试这个。

background-color: #8AB9FF !important;

Example: 例:

 *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .mygrid { margin: 0 0 20px 0; } &:after { content: ""; display: table; clear: both; } [class*='col-'] { float: left; padding-right: 20px; } .grid &:last-of-type { padding-right: 0; } .col-1-2 { width: 33.3%; } .col-2-3 { width: 66.6%; } .content { background-color: #8AB9FF !important; padding: 20px; } 
 <div class="mygrid"> <div class="col-1-2"> <div class="content"> <p>Text text text</p> </div> </div> <div class="col-2-3"> <div class="content"> <p>Text text text</p> </div> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM