2012-01-20 96 views
2

我想获得一个css类选择器来重写id选择器...我不想这样做的原因是因为我试图创建一个jQuery网站设计在左侧有框,当点击这些框时,任何打开的框最小化,并且单击打开框...框用第一个框id="box_n"的id表示,并且当打开框时它被给予类"selected"所以它可以被jQuery看作是当另一个框被选中时需要最小化的框。不过,我希望所选框可以滚动,因此"selected"类需要覆盖设置为scroll:hidden"box_n"标识滚动属性。有什么方法可以简单地做到这一点?这里是CSS,我有...有一个CSS类选择器覆盖CSS id选择器

.selected 
{ 
overflow: scroll; 
} 

#box_1 
{ 
background-color:#000; 
position: absolute; 
opacity: 0.6; 
top: 0px; 
left: -100px; 
margin-right:auto; 
float: left; 
height: 65px; 
width: 135px; 
border-radius:4px; 
-moz-border-radius:4px; /* Firefox 3.6 and earlier */ 
overflow:hidden; 
} 

和jQuery的是在这里:

$("#box_3") 
    .animate({ 
     width: largeWidth, 
     left: 60, 
     top: 0, 
     borderRadius: 10, 
     MozborderRadius: 10 
    }, (60), "swing") 
    .animate({ 
     height: largeHeight 
    }, (60), "swing") 
    .animate({ 
     opacity: 1 
    }, (160)); 

$("#box_3").addClass("selected"); 
selected = 1; 

感谢您的帮助!

回答

4

根据您的规则使用!important。它会让他们重写其他任何东西。

.selected 
{ 
    overflow: scroll !important; 
} 
+0

阿哈新有一个简单的修复!非常感谢你的帮助:) – simonthumper

1

尝试

.selected 
{ 
overflow: scroll!important; 
} 

这将增加溢出参数的权重上.selected箱。

+0

我想你错过了'!important'之前的空间,是不是? –

+0

有趣的是,我从来没有把“!重要”之前的空间。一直为我工作。到目前为止,该空间是可选的还是让浏览器对我宽容? – Andri

+0

值得一看在规格,我会检查当我在我的电脑旁边 –