【问题标题】:Calc percentage in IE11IE11中的计算百分比
【发布时间】:2020-01-18 20:17:21
【问题描述】:

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

【问题讨论】:

    标签: css sass css-calc


    【解决方案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>

    【讨论】:

      猜你喜欢
      • 2011-06-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-11
      • 2015-09-04
      • 2013-03-22
      相关资源
      最近更新 更多