CSS选择器有哪些?哪些属性可以继承?

本文详细介绍了CSS选择器的不同类型,包括通配符选择器、ID、类、标签选择器以及各种复杂的选择器用法,如后代、子、群组和伪类选择器。同时,文章探讨了CSS3中新增的选择器和继承特性,强调了哪些属性可以被继承,哪些则不能,如文本样式、盒模型属性等。
摘要由CSDN通过智能技术生成
选择器:

通配符(通用选择器) *    id选择器 #app          类选择器 .app            标签选择器 div

后代选择器  #app div      子选择器 #app>div     群组选择器 #app,.app 

相邻同胞选择器    div+p (选择紧接在<div>之后的所有<p>元素)

伪类选择器       :link   :visited   :active   :hover   :focus    :first-child

伪元素选择器     :first-letter :first-line :before :after :lang(language)

属性选择器      [attribute] [attribute=value] [attribute~=value] [attribute|=value]


CSS3新增选择器如下:

层次选择器	p~ul	选择前面有p元素的每个ul元素

伪类选择器	:first-of-type :last-of-type :only-of-type :only-child 
:nth-child(n) :nth-last-of-type(n) :last-child :root :empty :target 
:enabled :disabled :checked :not(selector)	

属性选择器	[attribute*=value] 选择属性中包含value值的属性
[attribute~=value] 是指包含value整个单词
选择属性以value开头的所有元素  [attribute^=value] 
选择属性以value结束的所有元素  [attribute$=value]	

css继承特性主要是指文本方面的继承,盒模型相关的属性基本没有继承特性。  

不可继承的: 
display、margin、border、padding、background、height、min-height、max-height、
width、min-width、max-width、overflow、position、top、bottom、left、right、z-index、
float、clear、 table-layout、vertical-align、page-break-after、page-bread-before
和unicode-bidi

所有元素可继承的: 
visibility和cursor 

终极块级元素可继承的: 
text-indent和text-align 

内联元素可继承的: 
letter-spacing、word-spacing、white-space、line-height、color、
font、font-family、font-size、font-style、font-variant、font-weight、
text-decoration、text-transform、direction 

列表元素可继承的: 
list-style、list-style-type、list-style-position、list-style-image
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值