有什么办法可以使css calc
函数的偏移量像IE11中所示的那样工作?
这在IE11中不起作用:
div:nth-child(1) {
background: hsl(114.54545, 44%, calc(55.88235% * 1.1));
}
静态百分比可以:
div:nth-child(2) {
background: hsl(114.54545, 44%, 55.88235%);
}
https://jsfiddle.net/d5hoe102/1/
最佳答案
您可以尝试使用额外的白色层对其进行近似以增加亮度,而无需calc()
div:nth-child(1) {
background: hsl(114.54545, 44%, calc(55.88235% * 1.1));
}
div:nth-child(2) {
background: hsl(114.54545, 44%, 55.88235%);
position:relative;
z-index:0;
}
div:nth-child(2):before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background:rgba(255,255,255,0.1);
}
<div>calc</div>
<div>static</div>
您也可以在多个背景下执行此操作:
div:nth-child(1) {
background: hsl(114.54545, 44%, calc(55.88235% * 1.1));
}
div:nth-child(2) {
background:
linear-gradient(rgba(255,255,255,0.1),rgba(255,255,255,0.1)),
hsl(114.54545, 44%, 55.88235%);
}
<div>calc</div>
<div>static</div>
关于css - IE11中的计算百分比,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57983183/