<body>
<div>content 1</div>
<div>content 2</div>
<div>content 3</div>
</body>
Run Code Online (Sandbox Code Playgroud)
如何在不使用任何id或类的情况下选择最后一个标签.我已经尝试过了:
body:last-child {
clear: both;
background-color:red;
}
Run Code Online (Sandbox Code Playgroud)
请帮忙
谢谢
但这是css3所以浏览器(ipad safari)不会识别它.
body:last-child 选择一个身体标签,它是其父母的最后一个孩子,试试
body > :last-child
Run Code Online (Sandbox Code Playgroud)
使用子选择器(>):
body > :last-child {
clear: both;
background-color:red;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3138 次 |
| 最近记录: |