css有N多属性,根据继承性,主要可以分为2大类
- 可继承属性
- 父标签的属性值会传递给子标签
- 一般是文字控制属性
所有标签可继承
| 属性 | 定义 | 取值 | 其它 |
|---|---|---|---|
| visibility | 可见 | hidden | 和display的区别,visibility保留宽高占位 |
| cursor | 光标样式 | pointer(手指)、crosshair(十字架) | -- |
内联标签可继承
| 属性 | 定义 | 常用取值 | 其它 |
|---|---|---|---|
| line-height | 设置垂直居中 | 像素值 | 水平居中使用text-aligntext-align(legt/right/center设置在父标签) |
| color | 文字颜色 | - | - |
| font-family | 设置文字的字体 | - | - |
| font-size | 设置文字的字体大小 | - | - |
| font-weigth | 加粗 | normal、bold | - |
| text-dexoration | 设置下划线 | none | - |
块级标签可继承
| 属性 | 定义 | 取值 | 其它 |
|---|---|---|---|
| text-indent | 锁进 | 百分数20% | - |
列表标签可继承
| 属性 | 定义 | 取值 | 其它 |
|---|---|---|---|
| list-style | 列表的头样式 | none |
- 不可继承属性
- 父标签的属性不能传递给子标签
- 一般是区块控制属性(布局类的属性:width,height,background)
不可继承属性
| 属性 | 定义 | 取值 | 其它 |
|---|---|---|---|
| display | |||
| margin | |||
| border | |||
| padding | |||
| background | 背景 | 颜色,图片(url("绝对路径和相对路径") | - |
| heigth | |||
| min-height | |||
| max-height | |||
| width | |||
| nin-width | |||
| max-width | |||
| overflow | |||
| position | |||
| left | |||
| right | |||
| top | |||
| bottom | |||
| z-index |