CSS中可继承、不可继承属性有哪些?

119 阅读1分钟

一、可继承的属性

字体属性

  • font-family:字体系列
  • font-weight:字体粗细
  • font-size:字体的大小
  • font-style:字体的风格

文本属性

  • text-align:文本水平对齐
  • text-indent:文本缩进
  • word-spacing:单词之间的间距
  • letter-spacing:字符串之间的间距
  • line-height:行高
  • text-transform:文本大小写(uppercase、lowercase、capitalize)
  • color:文本颜色

可见属性

  • visibility:控制元素显示隐藏

光标属性

  • cursor:光标样式

列表属性

  • list-style:列表风格

二、不可继承的属性

display

文本属性

  • vertical-align:垂直文本对齐
  • text-decoration:规定添加到文本的装饰
  • text-shadow:文本阴影效果
  • white-space:空白符的处理
  • unicode-bidi:设置文本的方向

定位属性

  • float
  • clear
  • position
  • top、right、bottom、left
  • overflow
  • z-index
  • ……

盒模型属性

  • width、height、margin、border、padding

背景属性

  • background、background-color、background-image、background-repeat、background-position、background-attachment

生成内容属性

  • content、counter-reset、counter-increment

轮廓样式属性

  • outline-style、outline-width、outline-color、outline

页面样式属性

  • size、page-break-before、page-break-after

声音样式属性

  • pause-before、pause-after、pause、cue-before、cue-after、cue、play-during