Less aggressive compilation with CSS3 calc

前端 未结 4 1509
臣服心动
臣服心动 2020-11-22 05:18

The Less compilers that I\'m using (OrangeBits and dotless 1.3.0.5) are aggressively translating

body { width: calc(100% - 250px - 1.5em); }
<
4条回答
  •  失恋的感觉
    2020-11-22 06:04

    A very common usecase of calc is take 100% width and adding some margin around the element.

    One can do so with:

    @someMarginVariable = 15px;
    
    margin: @someMarginVariable;
    width: calc(~"100% - "@someMarginVariable*2);
    width: -moz-calc(~"100% - "@someMarginVariable*2);
    width: -webkit-calc(~"100% - "@someMarginVariable*2);
    

提交回复
热议问题