css之div等继承问题--待续

div哪些属性是可以继承的呢?

亲测:float可以继承(错的,见下解答,),display不可以继承。有待继续学习。

float不可以继承, 简单来说:浮动的元素,顾名思义,就是这个元素“浮起来”了。所以它原本的位置被空了出来。有时候测试结果(也许你的测试不全面)并不能够说明子元素继承了float属性,只是视觉上有这个感觉。

  • css样式表属性可以继承的有如下:

        text-align;position;

  • display、border、margin和padding属性是不继承的。

        在所编写的规则中使用inherit的特殊值的话,可以让border、margin和padding被继承,但是display除外。

  • 链接样式继承:不同状态的链接样式,写在后面的状态样式可以继承写在前面的状态样式。
  • 不可继承的:display、margin、border、padding、background、height、min-height、max-height、width、min-width、max-width、overflow、position、left、right、top、bottom、z-index、float、clear、table-layoutvertical-alignpage-break-after、page-bread-before和unicode-bidi。
  • 所有元素可继承:visibility和cursor。
  • 内联元素可继承:letter-spacingword-spacingwhite-spaceline-height、color、font、font-family、font-size、font-style、font-variant、font-weighttext-decoration、text-transform、direction。
  • 终端块状元素可继承:text-indent和text-align。 列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。

文本相关属性:

azimuth, border-collapse, border-spacing,
caption-side, color, cursor, direction, elevation,
empty-cells, font-family, font-size, font-style,
font-variant, font-weight, font, letter-spacing,
line-height, list-style-image, list-style-position,
list-style-type, list-style, orphans, pitch-range,
pitch, quotes, richness, speak-header, speaknumeral,
speak-punctuation, speak, speechrate,
stress, text-align, text-indent, texttransform,
visibility, voice-family, volume, whitespace,
widows, word-spacing

列表相关属性:

azimuth, border-collapse, border-spacing,
caption-side, color, cursor, direction, elevation,
empty-cells, font-family, font-size, font-style,
font-variant, font-weight, font, letter-spacing,
line-height, list-style-image, list-style-position,
list-style-type, list-style, orphans, pitch-range,
pitch, quotes, richness, speak-header, speaknumeral,
speak-punctuation, speak, speechrate,
stress, text-align, text-indent, texttransform,
visibility, voice-family, volume, whitespace,
widows, word-spacing

----------------

----------------

参考http://www.cnblogs.com/super86/p/4121824.html  CSS样式表继承详解

原文地址:https://www.cnblogs.com/caiquan/p/5931622.html