feibenren
2015-04-07 09:30
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="">规则</a></li>
<li><a href="">论坛</a></li>
<li><a href="">安全</a></li>
<li><a href="">公益</a></li>
</ul>
你是指.tit>li a:last-of-type{background-color: red;} 这个属性出了问题吗?你这样写,所有的A标签的背景都会是红色,last-of-type的效果是指定最后一个元素的属性。如果你是想让最后一个A标签背景为红色,应该这样写 .tit>li:last-of-type a{background-color: red;} 。。
.tit>li a:last-of-type是指.tit下的第一个li标签下的最后一个a;
你应该是想表达tit>li:last-of-type a 吧
Tab选项卡切换效果
65465 学习 · 533 问题
相似问题