跟着老师在做,遇到一个问题,使用css3选择器,尽然不生效,但是又找不到问题处在哪里,好头疼

来源:1-4 js实现切换效果

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>


写回答 关注

2回答

  • 牙尖十怪
    2015-04-07 10:00:41
    已采纳

    你是指.tit>li a:last-of-type{background-color: red;} 这个属性出了问题吗?你这样写,所有的A标签的背景都会是红色,last-of-type的效果是指定最后一个元素的属性。如果你是想让最后一个A标签背景为红色,应该这样写    .tit>li:last-of-type a{background-color: red;} 。。

    feiben...

    非常感谢!

    2015-04-07 10:39:53

    共 1 条回复 >

  • 子木李
    2015-04-07 10:09:51

    .tit>li a:last-of-type是指.tit下的第一个li标签下的最后一个a;

    你应该是想表达tit>li:last-of-type a 吧

Tab选项卡切换效果

本课程详细介绍网页页面中最流行常用的tab切换效果

65465 学习 · 533 问题

查看课程

相似问题