SASS Won't Compile @import Google Font CDN

北城余情 提交于 2019-12-08 17:28:36

问题


I've had this issue lately on other developers SASS projects where the Google CDN import won't compile -- See screenshots, saves fine when commented out.

I read a few articles on this issue and it was suggested to do this command:

gem install compass

I don't use compass, I use a SASS plugin for Coda. Guessing the previous developer used Compass to compile? Figured this might help the compiling issue.


回答1:


The Sass import code should look like this:

@import url(http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,300,700);

You are importing from an URL, but your code is written as if you were importing a local file—that is why the error message says it can't be found.

Here's a little tutorial on how to use Google fonts with Sass.




回答2:


We can import separate Sass file in .scss

For example we have two file one in local directory of project and other one in on CDN server/online server (such as google fonts).

local file: css/nameofstylsheet.scss

&

Online Server: http://fonts.googleapis.com/cssfamily=Open+Sans:300italic,400italic,700italic,400,300,700);

we used them as:

@import "css/nameofstylsheet.scss";

@import url(http://fonts.googleapis.com/cssfamily=Open+Sans:300italic,700italic,400,300,700);


来源:https://stackoverflow.com/questions/26349982/sass-wont-compile-import-google-font-cdn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!