0

我想知道是否有任何方法可以将两个部分 id 定义为一段 css 代码。

目前,除了id之外,代码完全相同,有没有办法让两个id都在一段代码中,而不是复制相同的代码。例如

滑块#nav ul

#slider ul {
list-style-type:none;
height:80px;
width:620px;
background: rgb(206,220,231); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(206,220,231,1) 0%, rgba(89,106,114,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(206,220,231,1)), color-stop(100%,rgba(89,106,114,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cedce7', endColorstr='#596a72',GradientType=0 ); /* IE6-9 */
-webkit-box-shadow: inset 1px 1px 3px 1px ; 
box-shadow: inset 1px 1px 3px 1px ;
opacity:0.8;
}

#nav ul {
list-style-type:none;
height:80px;
width:620px;
background: rgb(206,220,231); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(206,220,231,1) 0%, rgba(89,106,114,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(206,220,231,1)), color-stop(100%,rgba(89,106,114,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(206,220,231,1) 0%,rgba(89,106,114,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cedce7', endColorstr='#596a72',GradientType=0 ); /* IE6-9 */
-webkit-box-shadow: inset 1px 1px 3px 1px ; 
box-shadow: inset 1px 1px 3px 1px ;
opacity:0.8;
}
4

1 回答 1

10

只需添加一个逗号。

#nav ul, #slider ul {
//Code
}

您的代码现在将应用于两个 id

于 2013-02-18T18:09:13.430 回答