网站页尾版权,网站导航用什么字体,深圳网站建设vr知识,网站内容与模板设计方案伪类选择器#xff1a;用来描述一个元素的特殊状态#xff01;比如第一个元素、某个元素的子元素、鼠标点击的元素
1 first-child/last-child /*ul的第一个子元素*/ ul li:first-child{ background: #0f35ad; } /*ul的最后一个子元素*/ ul li:last-child{ background: #0f3…伪类选择器用来描述一个元素的特殊状态比如第一个元素、某个元素的子元素、鼠标点击的元素
1 first-child/last-child /*ul的第一个子元素*/ ul li:first-child{ background: #0f35ad; } /*ul的最后一个子元素*/ ul li:last-child{ background: #0f35ad; } !DOCTYPE html
html langen
headmeta charsetUTF-8titleTitle/titlestyle/*ul的第一个子元素*/ul li:first-child{background: #0f35ad;}/*ul的最后一个子元素*/ul li:last-child{background: #0f35ad;}/style
/head
body
h1h1/h1
pp1/p
pp2/p
pp1/p
ullil1/lilil2/lilil3/li
/ul
/body
/html
浏览器翻译如下 2 nth-child() /*定位到父元素选择当前的第一个元素选择当前p元素的父级元素选中父元素的第一个并且是当前元素才有效*/ p:nth-child(1){ background: #0f35ad; } 注意如果第一个不是当前元素无效 浏览器翻译如下 3 nth-of-type() 浏览器翻译如下