css中可以和不可以继承的属性

不可继承的:

1 display、margin、border、padding、background
2 height、min-height、max- height
3 width、min-width、max-width、overflow
4 position、left、right、top、 bottom、z-index
5 float、clear、table-layout、vertical-align
6 page-break-after、 page-bread-before和unicode-bidi

不可继承:也就是指子节点不能继承父节点的属性

简单举例:

1 <div style="border: 1px solid #000;">
2     父节点
3     <p>这是子节点</p>
4 </div>

如图所示:

 

如果子节点能继承父节点的border属性,那么也会有一个红色边框。

所有元素可继承:

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

表格元素可继承:

border-collapse
相反,可继承就是父节点设置了这个属性后,子节点就可以继承他的属性,

权重的比较:

标签选择器(1)<类选择器(10)<id选择器(100)<行内样式<!important


因而它有更高的权重。当有多个规则都能应用于同一个元素时,权重越高的样式将被优先采用。而继承
属性的特性值为0;也就是说,任何一条与css继承值冲突的属性值都会覆盖继承的属性值!!!

posted @ 2016-10-19 16:02  一杯白水  阅读(254)  评论(0编辑  收藏  举报