Convert px to em in Less

后端 未结 7 1547
独厮守ぢ
独厮守ぢ 2021-01-01 07:34

What is the equivalent of Scss\' emCalc() in less?

padding: emCalc(24px);

in Scss will calculate em based on the viewpoint and

相关标签:
7条回答
  • 2021-01-01 08:06

    You could do this to convert px to em.

    @font-size: 16;         // Your base font-size in pixels
    @em: @font-size*1em;    // Shorthand for outputting ems, e.g. "12/@em"
    @rem: @font-size*1rem;  // Shorthand for outputting ems, e.g. "12/@rem"
    
    h1{
      font-size: 20/@em;
    }
    
    0 讨论(0)
提交回复
热议问题