gpt4 book ai didi

css - css 中的减号或下划线有什么作用吗?

转载 作者:技术小花猫 更新时间:2023-10-29 10:36:33 24 4
gpt4 key购买 nike

这个问题和我问的相似here .我正在清理一些文件,我在这个 css 中遇到了这个:


.something
{
height: 33px;
-height: 34px; /* does this do anything?? <em>/
}
</em>

.something
{
_width: 150px; /
does this do anything?? */
}

编辑:好的,所以 _(下划线)是 IE 的 css hack,这很好,我将保留它,但是减号呢,它有什么作用吗?

另外,我们不再支持 IE 7 以下的任何东西,所以如果有任何 IE6 的破解,我可以将其删除。

最佳答案

直接来自 W3C CSS 2.1 Spec -

4.1.2.1 Vendor-specific extensions

In CSS, identifiers may begin with '-' (dash) or '_' (underscore). Keywords and property names beginning with '-' or '_' are reserved for vendor-specific extensions.

然而,使用下划线作为 CSS 属性前缀是一个 well known CSS hack将该规则应用于 IE 6 中的呈现。

由于 CSS 标识符可以以“-”(破折号)开头并且有效,因此可用于在开发过程中快速注释掉部分 CSS。例如,在下面的 CSS 中,不会为 h1 设置任何属性,而只会为 h2 设置 margin

-h1 { color:blue; margin:2em; }
h2 { -color:pink; margin:2em; } /* property "-color" not valid */

关于css - css 中的减号或下划线有什么作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6521312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com