how to simplify font import in css

后端 未结 3 714
无人共我
无人共我 2021-01-26 00:47

I have a font namely SourceSansPro, and I include it in my css as follows:

@font-face {
    font-family: \"SourceSansPro\";
    src: url(\"../font/SourceSansPro-         


        
3条回答
  •  走了就别回头了
    2021-01-26 00:55

    Unfortunately the @font-face syntax is not very flexible. You're at the mercy of the browser developers in this case. You can, however, segment your fonts into a fonts.css file and just do an import:

    @import url('css/fonts.css');
    

    Another possible solution would be to add the font via Google's Font API. That way, you don't have to worry about the CSS in the first place. You just add

    @import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro);
    

    to your stylesheet. Or you can add

    
    

    to the of your document.

提交回复
热议问题