您的位置:首页 > Web前端 > CSS

在css中使用自定义字体

2017-01-20 13:35 453 查看
使用css3的#font-face属性

@font-face {
font-family: <YourWebFontName>;
src: <source> [<format>][,<source> [<format>]]*;
[font-weight: <weight>];
[font-style: <style>];
}


下面是我使用SourceCodePro的配置。(首先要把字体文件放进去)

@font-face {
font-family: 'SourceCodePro';
src: url('./assets/font/SourceCodePro.eot');
src: url('./assets/font/SourceCodePro.eot?#iefix') format('embedded-opentype'),     url('./assets/font/SourceCodePro.woff') format('woff'), url('./assets/font/SourceCodePro.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}


如果我们想定义某种字体的多种样式,可以配合sass使用,效果更好。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  css css3