css - 计算 IE11 中的百分比

标签 css sass css-calc

有没有办法让 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/

相关文章:

css - 带有reactjs的bootstrap scss不添加bootstrap类

html - 使用 calc() 时,宽度继承不会填充父级

css - 使用带有 Calc() 的 CSS 变量在第二个参数时不起作用

javascript - 页面扩展上的白色 div 页脚,如何?

css - SASS 看不到变量

ssl - .scss 中的 Assets 不像其他应用 Assets 那样使用 HTTPS 编译

html - 使用 CSS calc() 函数将元素保留在多余空间的中间

css - Bootstrap navbar-brand 标题在 navbar-nav 上方——怎么样?

jquery - 客户端条件验证 RequiredIf 属性

html - 容器缩小时缩小长选择/文本框输入的宽度