简体   繁体   English

中定义的CSS样式 <head> 没有申请?

[英]CSS styles defined in <head> not being applied?

I'm working on this page: http://sydneypadua.com/2dgoggles/ 我正在此页面上工作: http : //sydneypadua.com/2dgoggles/

And I'm trying to redefine the width of content-sidebar-wrap , in order to stop the left-hand sidebar being pushed down to the bottom of the page. 而且我正在尝试重新定义content-sidebar-wrap的宽度,以停止将左侧的侧边栏下推到页面底部。

Look in View Source and you will see where I have added the new style: 查看“查看源代码”,您将看到我在其中添加了新样式的地方:

.double-sidebar #content-sidebar-wrap {
    width: 795px ! important;
}

But use Chrome Developer Tools to inspect the styles being applied to the content-sidebar-wrap div, and you will only see: 但是,使用Chrome开发者工具检查应用于content-sidebar-wrap div的样式,您将仅看到:

width: 780px;
    .double-sidebar #content-sidebar-wrap - 780px style.css:596
    [with strikethrough] #content-sidebar-wrap - 960px style.css:591

Why isn't the style I have defined in the head of the page being picked up? 为什么我没有选择页面顶部定义的样式?

I tried to validate the css of your page and these errors came out into the page: 我试图验证页面的CSS,这些错误出现在页面中:

32  .double-sidebar #content-sidebar-wrap   Lexical error at line 33, column 1.  
     Encountered: "\ufffd" (65533), after : "" � � width: 795px !important;
33  .double-sidebar #content-sidebar-wrap   Parse Error }
45   *  Parse Error */ #content .post 
    { padding-left: 5px ! important; padding-right: 5px ! important; } 

Probably you inserted an unrecognized character (due to a copy and paste, maybe?) resulting in a parser error, so try to rewrite the entire rule. 您可能插入了无法识别的字符(可能是由于复制和粘贴?),导致解析器错误,因此请尝试重写整个规则。

For some reason the style tag doesn't like the id remove it and it should work fine. 由于某种原因,样式标签不喜欢id删除它,它应该可以正常工作。

<style     type="text/css">    
//no id ^
//Other rules...

/* Fix for sidebar widths. */

.double-sidebar #content-sidebar-wrap {
    width: 795px !important;
}

//other rules...

</style>

This is what I see in FF when I browse your css http://sydneypadua.com/2dgoggles/ : 这是我浏览您的CSS http://sydneypadua.com/2dgoggles/时在FF中看到的内容:

.double-sidebar #content-sidebar-wrap {
}

I'm sure "!important" shouldn't have a space. 我确定“!important”应该没有空格。

It should be 它应该是

#content-sidebar-wrap {
    width: 795px !important;
}

.double-sidebar is not needed because #content-sidebar-wrap determines div unambiguously. 不需要.double-sidebar ,因为#content-sidebar-wrap明确确定div。

Try removing the */ at the end of the .double-sidebar #sidebar-1-wrap class, because that could be breaking your css, and rewrite the css rule .double-sidebar #content-sidebar-wrap . 尝试删除.double-sidebar #sidebar-1-wrap类末尾的*/ ,因为这可能会破坏CSS,然后重写CSS规则.double-sidebar #content-sidebar-wrap

Also, just as a reminder, if you are styling ids, you don't need to specify a class before them, the selectors are read from right to left so with the id alone is enough 另外,提醒一下,如果您要对ID进行样式设置,则无需在它们之前指定一个类,那么选择器就会从右向左读取,因此仅使用ID就足够了

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

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