在制作網頁設計時,有時候怎需要用css控制第一個li標簽 或者 某個的樣式,和其他li的樣式不同,可以參考以下方法。
單獨設置第幾個LI的樣式,實例:
.contact-sub {
display: inline-block;
width: 30%;
margin-bottom: 35px;
position: relative;
line-height: 26px;
padding-left: 40px;
padding-right: 15px;
vertical-align: top
}
.contact-sub:nth-child(2n) {
width: 70%
}
|
偶數個和奇數個li標簽單獨設置樣式,實例:
.center_top_right ul li:nth-child(odd){ //奇數
list-style: none;
width: 90px;
height: 70px;
float: right;
}
.center_top_right ul li:nth-child(even){ //偶數
list-style: none;
width: 10px;
height: 70px;
color: #666;
float: right;
}
|