【问题标题】:What is the reason for the lack of inheritance of text-decoration? [closed]text-decoration缺乏继承的原因是什么? [关闭]
【发布时间】:2021-10-25 18:29:26
【问题描述】:

所以我已经阅读了关于这个主题的the previous disccussion,并且我知道文本装饰是传播而不是继承的,但是spec 并没有说明为什么。我试图更好地理解为什么会这样,以及为什么定位很重要。这种行为有什么好处?我对此感到惊讶,因为它不直观。 CSS 中是否还有其他我应该注意的示例?

【问题讨论】:

    标签: html css inheritance properties text-decorations


    【解决方案1】:

    考虑一下这个早于 CSS 的标记。

    <strike>The <a href="http://example.com/">example</a>is here.</strike>
    

    &lt;strike&gt; 默认为text-decoration:line-through&lt;a href="..."&gt; 默认为text-decoration:underline。在 CSS 之前,“示例”这个词会被下划线和删除,所以 CSS 需要能够实现相同的效果。为此,规范编写者选择让text-decoration 累积而不是继承。

    另一种方法是为每个text-decoration 值赋予其自己的属性。 CSS 之父 Håkon Wium Lie 在message to the www-style mailing list in May 1997 中解决了这个问题:

    没有也没有简单的方法来关闭闪烁 丢弃在 text-decoration 属性上设置的其他值。 这个 为了简洁而牺牲了——替代方案是 'text-decoration' 上的所有值都有单独的二进制属性。

    当时设想text-decoration 将扩展为拥有超过它最终拥有的四个装饰 - several had already been dropped from the draft spec

    所以你知道了,当时 CSS 的设计者不希望属性泛滥。


    很难证明这样的否定,但我不知道有任何其他以这种方式传播的属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多