您好,欢迎访问一九零五行业门户网

CSS 中 :first-child 伪类的用法

使用 :first-child 伪类向作为其他元素的第一个子元素的元素添加特殊样式。
示例 您可以尝试运行以下代码来了解 :first-child 伪类的用法 -
<html> <head> <style> div > p:first-child { text-indent: 25px; } </style> </head> <body> <div> <p>first paragraph in div. this paragraph will be indented</p> <p>second paragraph in div. this paragraph will not be indented</p> </div> <p>but it will not match the paragraph in this html:</p> <div> <h3>heading</h3> <p>the first paragraph inside the div. this paragraph will not be effected.</p> </div> </body></html>
以上就是css 中 :first-child 伪类的用法的详细内容。
其它类似信息

推荐信息