伪类和伪元素

选择第一个子元素:first-child

li:first-child{text-decoration: underline;}
    li:last-child{color: red;}
    p:first-child{font-style: italic;}
<p>xiaoren</p>
    <ul>
        <li>Insert Key</li>
        <li>Turn Key<strong>clockwise</strong></li>
        <li>Push accelerator</li>
    </ul>
    <ul>
        
        <li>这个也带下划线的 </li>
        <li>这个红色字体 </li>
    </ul>
    <ul>
        
        <li>下划线+红色字体 </li>
        
    </ul>
    <div>
        <p>first-child 为某元素第一个子元素为P元素设置为<em>斜体</em></p>
        <p>正常字体</p>
    </div>

 

posted on 2014-01-26 09:33  卡域克  阅读(230)  评论(0编辑  收藏  举报