Font Face Mixin for Less

前端 未结 7 602
暖寄归人
暖寄归人 2021-01-11 23:20

Using Less I am defining font-families as follows:

@georgia: georgia, times, \'times new roman\', \'nimbus roman no9 l\', serif; 

Then I ha

7条回答
  •  情深已故
    2021-01-11 23:29

    You could define your custom mixin for including custom fonts, but since LESS does not implement any control directives, only guards for mixins (which are useless in the current question's aspect), you cannot shorten the mixin's code for the font-face definition.

    .include-custom-font(@family: arial, @weight: normal, @style: normal){
        @font-face{
            font-family: @family;
            src:url('fonts/@{family}.eot');
            src:url('fonts/@{family}.eot?#iefix') format('embedded-opentype'),
                url('fonts/@{family}.woff') format('woff'),
                url('fonts/@{family}.ttf') format('truetype'),
                url('fonts/@{family}.svg#icon') format('svg');
            font-weight: @weight;
            font-style: @style;
        }
    }
    

提交回复
热议问题