gpt4 book ai didi

css - 如何在没有绝对位置的情况下为 mozilla firefox 在 CSS 中使用 calc

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:52 26 4
gpt4 key购买 nike

我会 like a div to be 100% height minus 197px在每个屏幕上。我使用了 CSS 函数 cal,如下所示。

<style>
#div1 {

left: 300px;
height: calc(100% - 197px);

border: 1px solid black;
background-color: yellow;

}
</style>

p>Create a div that stretches across the window, with a 50px gap between both sides of the div and the edges of the window:</p>
<div id="div1">Some text...</div>

到目前为止,它在大多数浏览器上都有效,除了 Firefox,它仅在我添加 position: absolute;

时有效

我的问题是 Position absolute 与我之前的一些代码产生了冲突。所以我的问题是如何在没有绝对位置的情况下为 mozila firefox 在 CSS 中使用 calc?

Jsfiddle

最佳答案

对于所有Mozilla和Safari,Chrome和IE所有版本都支持此代码

height:clac(100% - 197px);
height:-webkit-clac(100% - 197px);
height:-moz-clac(100% - 197px);

关于css - 如何在没有绝对位置的情况下为 mozilla firefox 在 CSS 中使用 calc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38810493/

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