ie8很奇葩 支持伪类 :first-child 但是不支持:last-child。但有些时候很想用last-child怎么办?
我发现一个可以解决这个问题的方法。(仅适用于同类有且仅有两个)
<style>
.main {width: 400px;height: 300px;border: 2px solid orange;}.main p:last-child {background: red;}
</style>
<div class="main">
<p>我是第一个p标签</p>
<p>我是第二个p标签</p>
</div>
解决办法:
css里变成
<style>
.main{width: 400px; height: 300px;border: 2px solid orange;}
.main p {background: red;}
.main p:first-child {background: #ffffff;}
</style>
请扫描二维码访问手机站!