样式继承

样式继承有如下规则:

  • 外层元素的样式,会被内层元素进行继承。
  • CSS文本属性(红色)、列表属性(蓝色)都会被继承
    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
  • 中的CSS属性,会被所有的子元素继承
  • font-size的子类继承的是计算后的值,浏览器默认字体大小是16px, p { font-size:85%} em将继承16px X 85% = 13.6px字体大小,实例请戳:inherit.html,咱们发现如果em还是继承的85%,这样em的字体大小会比H2还小了85%的大小,所以em继承的是计算后的13.6px。下面咱们看看这些样式属性的书写顺序:书写顺序

猜你喜欢

转载自blog.csdn.net/cuishizun/article/details/81979922
今日推荐