前言:在前期项目coding过程及牛客网刷题过程中,多次碰到CSS属性的继承,且在部分情况下混淆,故在此作总结记录。
CSS继承是指设置上级(父级)的CSS样式,上级(父级)及以下的子级(下级)都具有此属性。
- 元素可见属性: visability
- 字体系列属性
| 属性 | 含义 |
|---|---|
| font-family | 元素的字体系列 |
| font-wieght | 字体粗细 |
| font-size | 字体大小 |
| font-style | 字体风格 |
| font-variant | 字体显示文本 |
| font-size-adjust | 为某个元素规定一个aspect值,可以保持首选字体的x-height |
- 文本系列属性
| 属性 | 含义 |
|---|---|
| text-indent | 文本缩进 |
| text-align | 文本水平对齐 |
| line-height | 行高 |
| word-sapcing | 单词(字)之间的间隙 |
| leter-sapcing | 字符之间的间隙 |
| text-transform | 控制文本大小 |
| direction | 文字的书写方向 |
| color | 文字的颜色 |
- 表格布局属性
| 属性 |
|---|
| caption-side、border-collapse、border-spacing、empty-cells、table-layout |
- 列表布局属性
| 属性 |
|---|
| list-style-type、list-style-image、list-style-position、list-style |
-
生成内容属性 quotes
-
光标属性 cursor
-
页面样式属性
| 属性 |
|---|
| page、page-break-inside、windoes、orphans |
- 声音样式属性
- 显示样式属性: disaply
disaply:none时会使元素及其子元素都不可见。
- 文本属性
| 属性 | 含义 |
|---|---|
| vertial-align | 垂直文本属性 |
| text_decoration | 规定添加到文本的装饰 |
| text_shadow | 文本阴影效果 |
| white-space | 空白符的处理 |
| unicode-bidi | 设置文本的方向 |
-
盒子模型属性
-
背景属性: background相关
-
定位属性
| 属性 |
|---|
| float、clear、postiotion、top\right\bottom\left min-width、min-height、max-width、max-height overflow、clip、z-index |
- 生成内容属性
| 属性 |
|---|
| 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 |

本文总结了CSS中可继承与不可继承的属性。可继承属性包括:visability、字体系列、文本系列、表格布局、列表布局和生成内容属性等;不可继承的属性则涉及显示样式、文本属性、盒子模型、背景、定位、轮廓样式等。通过理解这些属性的继承特性,能更好地控制元素的样式和布局。
5519

被折叠的 条评论
为什么被折叠?



