中定义的 CSS 样式没有被应用?
我正在此页面上工作: http://sydneypadua.com/2dgoggles/
我正在尝试重新定义 content-sidebar-wrap
的宽度,以阻止左侧边栏被推到页面底部。
查看“查看源代码”,您将看到我在何处添加了新样式:
.double-sidebar #content-sidebar-wrap {
width: 795px ! important;
}
但是使用 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
为什么我在页面头部定义的样式没有被拾取吗?
I'm working on this page: 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.
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:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我尝试 验证页面的CSS并且这些错误出现在页面中:
可能您插入了一个无法识别的字符(可能是由于复制和粘贴?)导致解析器错误,所以尝试重写整个规则。
I tried to validate the css of your page and these errors came out into the page:
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.
这是我在浏览你的 css http://sydneypadua.com/2dgoggles/ 时在 FF 中看到的内容:
我确信“!important”不应该有空格。
This is what I see in FF when I browse your css http://sydneypadua.com/2dgoggles/ :
I'm sure "!important" shouldn't have a space.
应该是
.double-sidebar 不需要,因为 #content-sidebar-wrap 明确地确定了 div 。
It should be
.double-sidebar is not needed because #content-sidebar-wrap determines div unambiguously.
尝试删除
.double-sidebar #sidebar-1-wrap
类末尾的*/
,因为这可能会破坏您的 css,并重写 css 规则 <代码>.double-sidebar #content-sidebar-wrap。另外,提醒一下,如果您正在设计 id,则无需在它们之前指定类,选择器是从右到左读取的,因此仅使用 id 就足够了
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
.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,将其删除,它应该可以正常工作。
For some reason the style tag doesn't like the id remove it and it should work fine.