css快速引入字体文件

代码:

<!DOCTYPE html>
<html>
<head>
<style> 
	@font-face
	{
	font-family: myFirstFont;
	src: url('/example/css3/Sansation_Light.ttf')
	    ,url('/example/css3/Sansation_Light.eot'); /* IE9+ */
	}
	
	div
	{
	font-family:myFirstFont;
	}
</style>
</head>
<body>

<div>
With CSS3, websites can finally use fonts other than the pre-selected "web-safe" fonts.
</div>

<p><b>注释:</b>Internet Explorer 9+ 支持新的 @font-face 规则。Internet Explorer 8 以及更早的版本不支持新的 @font-face 规则。</p>

</body>
</html>

注意点:

1- src中引入的文件

引入.ttf.eot文件保证支持 谷歌和IE内核的浏览器

src: url('/example/css3/Sansation_Light.ttf')
    ,url('/example/css3/Sansation_Light.eot'); /* IE9+ */
}

2- 使用时,直接在font-family 使用改自提名字即可

font-family:myFirstFont;
发布了393 篇原创文章 · 获赞 303 · 访问量 134万+

猜你喜欢

转载自blog.csdn.net/qq_24147051/article/details/104921151