gpt4 book ai didi

css - 在 Firefox 中使用 transform() 和 calc()

转载 作者:行者123 更新时间:2023-11-28 10:12:58 24 4
gpt4 key购买 nike

我是否遗漏了一些明显的东西,或者 firefox 不喜欢在 transform:skewY() 中使用 calc() ?

问题

以下转换有效,没问题:

body article {
postion:relative;
top:50%;
transform-origin:left;
transform:skewY(-15deg) translateY(-50%);
}

但是尝试使用 calc() 不会。无论如何在 firefox 中都没有,尽管 chrome 按预期呈现了 skew() :

body article {
postion:relative;
top:50%;
transform-origin:left;
transform:skewY(calc(-1rad * 3.14 / 12)) translateY(-50%);
}

我通常认为这是 firefox 不做的事情,但他们的官方文档说:

The calc() CSS function can be used anywhere a length, frequency, angle, time, number, or integer is required.

(来源:https://developer.mozilla.org/en-US/docs/Web/CSS/calc#Browser_compatibility)

所以我认为错在我。任何人都可以看到转换中的语法有问题吗?

上下文

<html>
<body>
<article>
<header>title</header>
<div>article content</div>
</article

<!-- more articles... -->

</body>
</html>

CSS 看起来像这样:

body {
white-space:nowrap;
}
body article {
display:inline-block;
width:200px;
height:400px;
}
body article header {
height:50px;
}
body article div {
height:calc(100% - 50px);
}

我想要做的是在水平画廊中准确排列倾斜的元素。我也对任何横向思维持开放态度 =)

最佳答案

Bug 956573 - calc() CSS function doesn't work with all data types (units) that it should, such as times (从 2014 年开始,但仍然开放)在问题跟踪器中。

一条评论(同样来自 2014 年)有一段代码被注释 //calc() currently allows only lengths and percents inside it.

因为没有进一步的评论说现在支持更多的单位,而且考虑到评论仍在当前源代码 (49.0.1) 中,包括进一步的限制 请注意,在当前的实现中,数字不能与长度和百分比混合使用。我假设情况仍然如此,Firefox 仍然只支持长度和百分比。

if ((aVariantMask & VARIANT_CALC) &&
IsCSSTokenCalcFunction(*tk)) {
// calc() currently allows only lengths and percents and number inside it.
// And note that in current implementation, number cannot be mixed with
// length and percent.
if (!ParseCalc(aValue, aVariantMask & VARIANT_LPN)) {
return CSSParseResult::Error;
}
return CSSParseResult::Ok;
}

关于css - 在 Firefox 中使用 transform() 和 calc(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39806840/

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