使用CSS3:不使用IE选择器 - 使用Prototype

时间:2010-10-25 10:04:22

标签: css css3 css-selectors prototypejs

我需要为内容<div>添加CSS样式,该内容存在于我网站的所有页面上。但是,我不想在主页上使用新样式。

网站上的所有网页都有类似的结构:带有导航栏的标题<div>,后跟带有网页内容的内容<div>

我能想到的最好是在主页上的内容div下直接添加一个包装div,就像这样......

<div id="content">
   <div id="homepage_content">
      ....homepage content....

然后,我可以使用<div>选择器将我的样式应用于整个内容:not,因此homepage_content下的元素不会包含在内。

这在IE中不起作用。我已经看过它的jQuery解决方法,但我们在我的网站上使用Prototype。

任何人都有我的想法?

谢谢!

2 个答案:

答案 0 :(得分:1)

其实不是not an option yet

对于这一点,肯定有基于Prototype的解决方法,但纯CSS解决方案可能更为可取。

也许通过在其他对象周围添加另一个不可见的容器来解决这个问题?

<div id="content">
   <div class="other_elements">
    .... the other elements you want to style ....
   </div>
   <div id="homepage_content">
      ....homepage content....
</div>

然后解决其他对象,如

#content .other_elements elementname {  ...... }

这是否可行,取决于你的CSS结构。

答案 1 :(得分:1)

您可以在主页上使用以下HTML:

<div id="content" class="home-page">

每隔一页都有以下HTML:

<div id="content" class="regular-page">

然后添加你的CSS样式:

#content.regular-page {
    /* Styles here */
}
相关问题