使用less编译出css引用自定义字体
2014-11-29 10:33
197 查看
编写less文件如下
编译出来的css如下
参考:
在线less编译网址:http://tool.oschina.net/less
字体文件:http://pan.baidu.com/s/1kTA7Kub
@roboto-font-path: 'fonts'; .roboto-font(@type, @weight, @style) { @font-face { font-family: 'Roboto'; src: url('@{roboto-font-path}/Roboto-@{type}.ttf') format('truetype'); font-weight: @weight; font-style: @style; } } .roboto-font-one(@type, @weight, @style) { .roboto-font('@{type}', @weight, @style); } .roboto-font-pair(@type, @weight) { .roboto-font('@{type}', @weight, normal); .roboto-font('@{type}Italic', @weight, italic); } .roboto-font-one('Italic', 200, italic); .roboto-font-one('Regular', 400, normal); .roboto-font-pair('Thin', 100); .roboto-font-pair('Light', 300); .roboto-font-pair('Medium', 500); .roboto-font-pair('Bold', 700); .roboto-font-pair('Black', 900);
编译出来的css如下
@font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Italic.ttf') format('truetype'); font-weight: 200; font-style: italic; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Thin.ttf') format('truetype'); font-weight: 100; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-ThinItalic.ttf') format('truetype'); font-weight: 100; font-style: italic; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-LightItalic.ttf') format('truetype'); font-weight: 300; font-style: italic; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-MediumItalic.ttf') format('truetype'); font-weight: 500; font-style: italic; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-Black.ttf') format('truetype'); font-weight: 900; font-style: normal; } @font-face { font-family: 'Roboto'; src: url('fonts/Roboto-BlackItalic.ttf') format('truetype'); font-weight: 900; font-style: italic; }
参考:
在线less编译网址:http://tool.oschina.net/less
字体文件:http://pan.baidu.com/s/1kTA7Kub
相关文章推荐
- css网页使用自定义字体方法
- Html使用CSS自定义字体的总结
- 在 vue-cli 脚手架中引用 jQuery、bootstrap 以及使用 sass、less 编写 css [vue-cli配置入门]
- css自定义字体font-face的兼容和使用
- vue中使用less编译css
- css使用自定义字体
- CSS unicode-range特定字符使用font-face自定义字体
- 使用Python编译less格式的css代码
- 使用sublimeText3编译less后css被压缩解决办法
- css学习之一使用自定义字体
- 编辑自定义字体及生成可引用的CSS文件
- 【备用】标准CSS引用自定义字体格式
- css 自定义字体的使用方法
- css 使用@font-face 嵌入自定义字体或字体图标方法笔记
- 详解在vue-cli中引用jQuery、bootstrap以及使用sass、less编写css
- 使用nodeJs来安装less及编译less文件为css文件的方法
- 在 vue-cli 脚手架中引用 jQuery、bootstrap 以及使用 sass、less 编写 css [vue-cli配置入门]
- 使用sublimeText3编译less后css被压缩解决办法
- HTML5 Canvas绘文本动画(使用CSS自定义字体)
- CSS: 引用字体文件,以及字体图标的使用