CSS3自定义字体写法
CSS3自定义字体写法 ps:最好英文 中文字体太大 影响加载速度 (中文字体网上的ttf大多数是gb2312 不过页面UTF-8格式可以用 不会乱码 <meta charset="UTF-8"> 会自动转化为utf-8) <pre> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> @font-face { font-family: myFirstFont; src: url('Sansation-Light.ttf') } .ew { font-family:myFirstFont; } </style> </head> <body> <div class="ew"> With CSS3, websites can finally use fonts other than the pre-selected "web-safe" fonts </div> </body> </html> </pre> myFirstFont这个是自定义字体标识 可以自定义 注意和上面font-face对应就行了 ps:一定要在window.onload 后面显示该文字 因为一定要确保字体下载好后显示 如果无法显示 看看是不是下载失败了 谷歌inspect打开 看看font面板 有没有下载 没有说明下载失败了 console