用字体在网页中画ICON图标-学习一
1.从https://icomoon.io下载icon
2.引用样式字体
@font-face {
font-family: 'icomoon';
src:url('fonts/icomoon.eot');/*IE9兼容模式,如果在非兼容模式,图标不能正常使用*/
src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),/*解决web字体在Ie-6-8字体,使用?号可解决这个问题*/
url('fonts/icomoon.ttf?#iefix') format('truetype'),/*解决web字体在Ie-6-8字体,原因:有多个字体时,IE浏览器不能正常显示*/
url('fonts/icomoon.woff?#iefix') format('woff'),
url('fonts/icomoon.svg?#iefix') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;/*这个属性可以使页面上的字体抗锯齿,使用后字体看起来会更清晰舒服*/
-moz-osx-font-smoothing: grayscale;/*这个属性也是更清晰的作用,特别是图标文字流行的今天。*/
}
3.调用
方法一,写样式
.icon-spades:before {
content: "\e917";
}
.icon-clubs:before {
content: "\e918";
}
方法二,直接写值
<div id="box" class="icon">
 红色是固定的
</div>

浙公网安备 33010602011771号