跟著老師在做,遇到一個(gè)問題,使用css3選擇器,盡然不生效,但是又找不到問題處在哪里,好頭疼
CSS:
<style type="text/css">
.tit>li a{display: inline-block; float: left; width:60px;height: 27px;
text-align: center;border-right: 1px solid #eee;
border-bottom: 1px solid #eee;line-height: 27px;
text-decoration: none;background-color: #F7F7F7;}
.tit>li a:last-of-type{background-color: red;}
</style>
HTML代碼:
<ul class="tit">
<li><a href="">公告</a></li>
<li><a href="">規(guī)則</a></li>
<li><a href="">論壇</a></li>
<li><a href="">安全</a></li>
<li><a href="">公益</a></li>
</ul>
2015-04-07
你是指.tit>li a:last-of-type{background-color: red;} 這個(gè)屬性出了問題嗎?你這樣寫,所有的A標(biāo)簽的背景都會是紅色,last-of-type的效果是指定最后一個(gè)元素的屬性。如果你是想讓最后一個(gè)A標(biāo)簽背景為紅色,應(yīng)該這樣寫????.tit>li:last-of-type a{background-color: red;} 。。
2015-04-07
.tit>li a:last-of-type是指.tit下的第一個(gè)li標(biāo)簽下的最后一個(gè)a;
你應(yīng)該是想表達(dá)tit>li:last-of-type a 吧