这个 CSS 值是什么意思?

发布于 2024-07-22 11:14:28 字数 192 浏览 5 评论 0原文

在查看网页源代码时,我遇到了这个 CSS,应用于按钮内的跨度:

.whatever button span {
    position: absolute;
    left: -1e+7px;
}

left: -1e+7px; 是什么意思? 这是我应该注意的技巧吗?

While viewing the source of a web page, I came across this CSS, applied to a span within a button:

.whatever button span {
    position: absolute;
    left: -1e+7px;
}

What does left: -1e+7px; mean? Is this some trick I should be aware of?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陪你搞怪i 2024-07-29 11:14:28

It appears to be scientific notation (in this case, for -10,000,000px). To the best of my knowledge, CSS does not allow scientific notation (it is absent from the standard, but a Google search for "css scientific notation" turns up several complaints against Batik — an SVG engine — for not supporting it). I would guess that some CSS parsers do support such notation, despite it not being part of the standard, but if so, I cannot find information on which parsers support it.

To be safe, I would avoid using it in your own stylesheets.

独守阴晴ぅ圆缺 2024-07-29 11:14:28

根据关于数字的 CSS2 规范,


某些值类型可能具有整数值(用 ~integer~ 表示)或实数值(用 ~number~ 表示)。 实数和整数仅以十进制表示法指定。 〜整数〜由一位或多位数字“0”到“9”组成。 〜数字〜可以是〜整数〜,也可以是零个或多个数字,后跟一个点(.),后跟一个或多个数字。 整数和实数前面都可以带有“-”或“+”来指示符号。 -0 相当于 0 并且不是负数。


IE 接受科学计数法。 火狐浏览器会忽略它。

From the CSS2 spec on Numbers


Some value types may have integer values (denoted by ~integer~) or real number values (denoted by ~number~). Real numbers and integers are specified in decimal notation only. An ~integer~ consists of one or more digits "0" to "9". A ~number~ can either be an ~integer~, or it can be zero or more digits followed by a dot (.) followed by one or more digits. Both integers and real numbers may be preceded by a "-" or "+" to indicate the sign. -0 is equivalent to 0 and is not a negative number.


IE accepts scientific notation. Firefox ignores it.

黎夕旧梦 2024-07-29 11:14:28

CSS 支持科学记数法吗? 他们是否试图将按钮放在一边一千万像素,也许有一个不可见的默认按钮?

Does CSS support scientific notation? Are they trying to put the button ten million pixels off to the side, maybe to have a default button that's not visible?

找个人就嫁了吧 2024-07-29 11:14:28

这是科学记数法,意思是-1*10^7 = -10000000。

This is scientific notation, meaning -1*10^7 = -10000000.

落叶缤纷 2024-07-29 11:14:28

根据 W3C 验证器,这不是有效的 CSS:

.whatever button span    Value Error : position attempt to find a semi-colon before the property name. add it
.whatever button span    Value Error : left Unknown dimension 1e

如果添加缺少的 ;position:absolute 之后,你仍然得到:

whatever button span     Value Error : left Unknown dimension 1e

That is not valid CSS, according to the W3C validator:

.whatever button span    Value Error : position attempt to find a semi-colon before the property name. add it
.whatever button span    Value Error : left Unknown dimension 1e

If you add the missing ; after position: absolute, you still get:

whatever button span     Value Error : left Unknown dimension 1e
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文