示例:我想从文件导入SVG(在CSS中对其进行硬编码),例如。
$svg-icon: @import('./icon.svg');
这是否可以使用SASS?
答案 0 :(得分:-3)
听起来你想从svg文件创建一个图标字体。请按照以下步骤操作:
.icon-home2:before {
content: "\e900";
}

8.1复制代码并将其粘贴到scss或css文件的顶部。
点击右下角的下载按钮。
在新的zip文件夹中,转到 fonts 文件夹,然后将eot,svg,ttf和woff文件粘贴到应用程序中的某个位置。
将以下代码写在SCSS文件的顶部(在您之前复制粘贴的代码上方)
@font-face {
font-family: 'newFont';
src:url('<location of your eot file>');
src:url('<location of your eot file>?#iefix') format('embedded-opentype'),
url('<location of your woff file>') format('woff'),
url('<location of your ttf file>') format('truetype'),
url('<location of your svg file>') format('svg');
font-weight: normal;
font-style: normal;
}
&#13;
将新样式分配给dom节点(在本例中为类 icon-home2 的节点)
你最后的scss(或css)看起来应该是这样的。
@font-face {
font-family: 'newFont';
src:url('<location of your eot file>');
src:url('<location of your eot file>?#iefix') format('embedded-opentype'),
url('<location of your woff file>') format('woff'),
url('<location of your ttf file>') format('truetype'),
url('<location of your svg file>') format('svg');
font-weight: normal;
font-style: normal;
}
.icon-home2:before {
content: "\e900";
font-family: "newFont";
font-size: 20px;
color: #f47920;
}
&#13;