摸鱼复习css2

可继承属性
所有元素: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
表格布局属性:caption-side、border-collapse、border-spacing、empty-cells、table-layout
文本属性:text-transform、direction
其它属性:letter-spacing、word-spacing
文本属性:white-space

text-indent、text-align、text-decoration、text-shadow

不可继承属性
盒子模型所有属性:margin、padding、border、width、height
轮廓及背景属性:outline、background
定位、显示、浮动属性:display、position、top、left、right、bottom、max-(如max-height等)、min-、overflow、clear、float、content、z-index、vertical-align
其它:display

注意点: 对于天生自带的继承属性我们可以控制它是否需要继承

四个属性

inherit: 被应用属性继承父级的该属性(默认就是该值)
initial初始化,把应用属性初始为它默认的样式,并且排除继承的干扰(默认会继承的属性也不在默认继承,而是表现出没有任何设置时候的默认样式)
unset:意思是恢复其原本的继承方式。对color属性而言,就相当于inherit;而对于诸如border这样默认不继承的属性,就相当于initial。
revert: 效果等同于unset且浏览器支持有限,这里不做演示

如果我们需要控制元素所有属性的继承使用all属性
.inherit a {
all: initial;
}

继承权重是0.伪元素当元素处理,伪类就是类

注意:
p {
text-decoration: underline overline line-through;
}
上述规则会为段落文本同时增加上划线、下划线和中间贯穿线

text-decoration: undeline
想在子元素删除
text-decoration: none;
清除不了
因为text-decoration会叠加,可以把display: 设置成行内块可以解决

2.行内元素设置padding和margin,只对左右有效果

猜你喜欢

转载自blog.csdn.net/weixin_45295262/article/details/118810703