日期:2014-05-17  浏览次数:20677 次

伪类:first-child无效
很简单的一段代码:
HTML code

.index_av .intro { width:99px; margin-left:18px; float:left; }
.index_av .intro:first-child { margin-left:8px; }

<div class="index_av f_l">
        <div class="title">Confident tutors (with video/audio presentation)</div>
        <div class="intro">
            <img src="/picture.php?path={%$vol.Photo%}&w=93&h=118" border="0">
        </div>
        <div class="intro">
            <img src="/picture.php?path={%$vol.Photo%}&w=93&h=118" border="0">
        </div>
        <div class="intro">
            <img src="/picture.php?path={%$vol.Photo%}&w=93&h=118" border="0">
        </div>
        <div class="intro">
            <img src="/picture.php?path={%$vol.Photo%}&w=93&h=118" border="0">
        </div>
        <div class="intro">
            <img src="/picture.php?path={%$vol.Photo%}&w=93&h=118" border="0">
        </div>
    </div>



针对第一个.intro, margin-left仍是18px,而不是8px;而且IE8和FF的效果都是一样的,实在想不出是什么原因。

------解决方案--------------------
.index_av .intro:first-child { margin-left:8px; }
.intro不是.index_av的第一个子元素不会有效果