首页 > 编程学习 > 详解:9only-child only-of-type

only-child只有一个子元素的css样式
only-of-type只有一个元素的css样式

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title><style type="text/css">.box1 p:only-child/*只有一个儿子的就样式化*/{color: blue;}.test1 h2:only-of-type/*意思是*/{color: red;}</style>
</head>
<body><div class="box1"><p>hello king</p></div><div class="box1"><p>hello king</p><p>hello king</p></div><div class="test1"><h2>55</h2></div>
</body>
</html>

本文链接:https://www.ngui.cc/el/2926762.html
Copyright © 2010-2022 ngui.cc 版权所有 |关于我们| 联系方式| 豫B2-20100000