什么是使用CSS中的“初始”的价值? [英] What is use of 'initial' value in CSS?

查看:109
本文介绍了什么是使用CSS中的“初始”的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为初始值将恢复最初呈现样式(如应用通过的的浏览器的内部的用户代理的样式表)。

I thought that the initial value would restore initially rendered styles (as applied by a browser's internal user-agent stylesheet).

例如:

div.inline {
  display: inline;
}

div.initial {
  display: initial;
}

我所期望的 div.inline 规则将显示&LT; D​​IV CLASS =内联&GT; 内联使用 A <$;模式, div.initial 规则将显示&LT; D​​IV CLASS =初始&GT C $ C> DIV 中的原始的显示值

I expected the div.inline rule would display <div class="inline"> in inline mode, and the div.initial rule would display <div class="initial"> using a div's original display value of block.

但是,当我探讨这个,&LT; D​​IV CLASS =初始&GT;内联显示。我错了吗?任何人都可以更多地讨论这个?

But when I explore this, <div class="initial"> displays inline. Am I wrong? Can anyone elaborate more on this?

推荐答案

初始价值(不属性)表示属性的初始值,如CSS规范定义的:被指定为初始的关键字重新presents规定值该属性的初始值,因此,它的含义取决于财产,但没有任何其他问题,例如:不上的浏览器或该属性被施加到元件上。所以它的的意思是浏览器的默认。

The initial value (not attribute) denotes the initial value of the property, as defined in CSS specifications: "The ‘initial’ keyword represents the specified value that is designated as the property's initial value." Thus, its meaning depends on the property, but not on anything else, e.g. not on the browser or on the element that the property is being applied to. So it does not mean browser default.

例如,对于显示属性,初始总是的手段在线,因为这是物业指定的初始值。在这个例子中的情况下,的浏览器的默认的是,因为该元素是 DIV

For example, for the display property, initial always means inline, because that’s the designated initial value of the property. In the example case, the browser default is block, since the element is div.

因此​​,初始价值是有限的用处。它的主要作用似乎是蛊惑人心,因误解。一个可能的用例是颜色属性,因为它的初始值是依赖于浏览器(主要是黑人,因为我们知道,但不一定)。对于它,初始意味着浏览器的默认,因为这是如何的财产已经被定义,类似的用例是 FONT-FAMILY :通过声明 FONT-FAMILY:初始,你的浏览器的默认字体(这可能依赖于浏览器的设置)

Thus, the initial value is of limited usefulness. Its main effect seems to be to confuse people, due to misunderstandings. A possible use case is for the color property, since its initial value is browser-dependent (mostly black, as we know, but not necessarily). For it, initial means browser default, since that’s how the property has been defined, A similar use case is for font-family: by declaring font-family: initial, you get browser’s default font (which may depend on browser settings).

的用处是进一步缺乏对IE浏览器(IE,甚至10)的支持有限。

The usefulness is further limited by lack of support on IE (even IE 10).

这篇关于什么是使用CSS中的“初始”的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆