过去,Web设计师为了保证网站可以正常显示,只能使用“Web安全字体”,即每台机器都预装的字体。但Web安全字体有时并很差看...css
@font-face可以使得任何一台机器可以显示理想中的字体。web
这里咱们只要知道有这些格式的字体文件便可,不用背下来。数据库
定义字体api
@font-face {浏览器
font-family: <name>;
src: <source> [<format>][,<source> [<format>]]*;
[font-weight: <weight>];
[font-style: <style>];
}安全
使用字体svg
font-family: <name>;工具
@font-face 规则模板字体
@font-face { font-family: 'bradley_hand_itcregular'; src: url('bradhitc-webfont.eot'); /* IE9 Compat Modes */ src: url('bradhitc-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('bradhitc-webfont.woff') format('woff'), /* Modern Browsers */ url('bradhitc-webfont.ttf') format('truetype'), /* Safari, Android, iOS */ url('bradhitc-webfont.svg#bradley_hand_itcregular') format('svg'); /* Legacy iOS */ font-weight: normal; font-style: normal; }
引入:网站
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
font-family: 'Open Sans', sans-serif;