下载好字体文件,而后在网页中引入,用src: url('my.otf');来引入,使用的时候就使用本身定义的名字来使用这个字体。css
7 @font-face 8 { 9 font-family: my; 10 src: url('my.otf'); 11 }
13 *{ 14 font-family: my; 15 }
在style里面html
@font-face
网页中的字体用户电脑没有,服务器上也没有的问题linux
如今只要网站有就能够啦css3
声明字体的时候会指定名字,用的时候直接使用这个名字就能够了服务器
7 @font-face 8 { 9 font-family: my; 10 src: url('my.otf'); 11 } 12 13 *{ 14 font-family: my; 15 }
1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>index</title> 6 <style> 7 @font-face 8 { 9 font-family: my; 10 src: url('my.otf'); 11 } 12 13 *{ 14 font-family: my; 15 } 16 17 div{ 18 width:500px; 19 height:300px; 20 } 21 22 </style> 23 </head> 24 <body> 25 <div> 26 <p>我是小金,我爱睡觉!</p> 27 <p>linux is very much!</p> 28 <p>linux is very much!</p> 29 <p>linux is very much!</p> 30 <p>linux is very much!</p> 31 </div> 32 </body> 33 </html>