中定义的 CSS 样式没有被应用?

发布于 2025-01-01 23:35:10 字数 601 浏览 0 评论 0原文

我正在此页面上工作: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

丑疤怪 2025-01-08 23:35:10

我尝试 验证页面的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; } 

可能您插入了一个无法识别的字符(可能是由于复制和粘贴?)导致解析器错误,所以尝试重写整个规则。

I tried to validate the css of your page and these errors came out into the page:

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.

另类 2025-01-08 23:35:10

这是我在浏览你的 css http://sydneypadua.com/2dgoggles/ 时在 FF 中看到的内容:

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

我确信“!important”不应该有空格。

This is what I see in FF when I browse your css http://sydneypadua.com/2dgoggles/ :

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

I'm sure "!important" shouldn't have a space.

-小熊_ 2025-01-08 23:35:10

应该是

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

.double-sidebar 不需要,因为 #content-sidebar-wrap 明确地确定了 div 。

It should be

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

.double-sidebar is not needed because #content-sidebar-wrap determines div unambiguously.

鹤舞 2025-01-08 23:35:10

尝试删除 .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

金橙橙 2025-01-08 23:35:10

由于某种原因,样式标签不喜欢 id,将其删除,它应该可以正常工作。

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

/* Fix for sidebar widths. */

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

//other rules...

</style>

For some reason the style tag doesn't like the id remove it and it should work fine.

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

/* Fix for sidebar widths. */

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

//other rules...

</style>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文