Is it possible to import fonts from the directory with scss?

前端 未结 3 2134
忘了有多久
忘了有多久 2021-02-18 13:10

I have a scss file with font import implemented this way:

@import url(https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin-ext,cyrill         


        
相关标签:
3条回答
  • 2021-02-18 13:57

    it's a bit late but you can use the following format with libsass for external imports

    @import url("http...");

    0 讨论(0)
  • 2021-02-18 14:02

    As far as I know you can't import fonts using @import in SCSS. You can include fonts using @font-face. For example:

    @font-face {
        font-family: 'Open Sans';
        src: url(path/to/file) format(Example: 'truetype' or 'opentype' depending on the file extension of your font);
    }
    
    
    // USAGE
    body {
        font-family: 'Open Sans', sans-serif;
    }
    
    0 讨论(0)
  • 2021-02-18 14:07

    Usually it's used to import CSS fragments or files and not fonts. Try this workaround if you are using Ruby SASS/SCSS and try without brackets.

    @import "https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin-ext,cyrillic.css"; 
    

    I put a .css behind it. Works for me with Ruby SASS/SCSS but not with LibSass though.

    0 讨论(0)
提交回复
热议问题