CSS 计算不工作,即 11

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25241762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:28:32  来源:igfitidea点击:

calc not working ie 11

csscross-browsercss-calc

提问by Ahmed-Anas

After researching I confirmed that calc should work for ie8+ but it is not working for me.

经过研究,我确认 calc 应该适用于 ie8+,但它对我不起作用。

Here is a JS fiddle I made:

这是我制作的 JS 小提琴:

http://jsfiddle.net/75tzyLoo/

http://jsfiddle.net/75tzyLoo/

here is the code: HTML:

这是代码:HTML:

<div id="outer">
    <div id="inner">

    </div>
</div>

CSS:

CSS:

#outer{
    width:400px;
    background-color:black;
    height:200px;
}
#inner{
    width:calc(80%-100px);
    width:expression(80%-100px);
    background-color:red;
    height:100%;

}

and here is the output I see: JS Fiddle output for calc not working

这是我看到的输出: 用于计算的 JS Fiddle 输出不起作用

What am I doing wrong?

我究竟做错了什么?

回答by JunM

"-" should be surrounded with spaces width:calc(80% - 100px);

“-”应该用空格包围 width:calc(80% - 100px);

Demo

Demo

回答by 4dgaurav

Demo

演示

width:calc(80%-100px);change to width:calc(80% - 100px);(space between '-' sign)

width:calc(80%-100px);更改为width:calc(80% - 100px);('-' 符号之间的空格)