CSS中属性可以继承及不可继承详解

html-css07

CSS中属性可以继承及不可继承详解,第1张

一、不能继承的属性

① 盒子模型所有属性:margin、padding、border、width、height。

② 轮廓及背景属性:outline、background。

③ 定位、显示、浮动属性:display、position、top、left、right、bottom、max-*(如max-height等)、overflow、clear、float、content、z-index。

④ 其他:vertical-align、text-decoration、text-shadow、white-space。

注意:内联元素不能继承:text-indent和text-align,但是块级元素可以。

二、元素可继承属性

① 所有元素可继承:visibility、cursor。

② 列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。

③ 字体属性:line-height、color、font、font-family、font-size、font-style、font-variant、font-weight、font-size-adjust。

④ 文本属性:text-transform、direction,除了(text-decoration、text-shadow 内联元素不能继承 ) 块级 可继承。

⑤ 表格布局属性:caption-side、border-collapse、border-spacing、empty-cells、table-layout。

⑥ 其它属性:letter-spacing、word-spacing。

如果还有您知道的,希望可以留言补充。

如果喜欢,不要吝啬你的爱心“❤”哦!

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

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

内联元素可继承: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。

终端块状元素可继承:text-indent和text-align。

列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。