css_1
时间:2023-03-30 19:08:01
CSS
四。什么是css选择器?哪些属性可以继承css选择器:id选择器(#id)、类选择器(.class)、标签选择器(divph1-h6emstrong等),相邻选择器(h1+p)、子选择器(ul>li)、背景选择器(lia)、通配符选择器(*)、属性选择器(a[name='content'])、伪类选择器(a:hover,li:nth-child)可继承属性:font-size,font-weightfont-family等以font,color开头的属性不可继承属性:borderpaddingmarginwidthheight等优先级(就近原则):!important>[id>class>tag]!important比行内优先级高5。css优先级算法如何计算!important最高内联样式:1000Id选择器:100类选择器伪类选择器属性选择器:10标签选择器:1一般选择器,子选择器,相邻兄弟选择器:0六。css3newpseudoclass其中p:first-of-type对应p:first-child父元素的第一个元素p:last-of-type对应p:last-child父元素的最后一个元素p:only-of-type对应p:only-child父元素p:nth-of-type(2)的唯一子元素对应p:nth-child(2)父元素p:nth的第二个子元素-last-of-type对应p:nth-last-child(2)父元素的第二个子元素,从最后一个元素算起:enabled:disabled表单控件的禁用状态:checkedRadio框或复选框被选中:not:not(p)selectnon-pEVERYELEMENTOFELEMENTS:root选择文档的根元素:emptyp:empty选择没有子元素的每个p元素:target#news:target选择当前活动的#news元素[attr^=value]a[name^='abc']匹配属性名称以abc[attr$=value]开头的所有a元素a[name^='abc']匹配属性名称以结尾的所有a元素abc[attr*=value]a[name^='abc']匹配属性name的值包括abc::selection的所有元素被用户选中