<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css p:last-child</title> <style> /*参考:https://www.runoob.com/cssref/sel-last-child.html 知识点: :last-child选择器用来匹配父元素中最后一个子元素。 提示: p:last-child等同于p:nth-last-child(1)。*/ /*指定p元素的父元素中最后一个p元素的背景色。*/ p:last-child { background: #ff0000; } </style> </head> <body> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>The fourth paragraph.</p> </body> </html>
css p:last-child.html
最新推荐文章于 2023-05-22 19:43:03 发布