Adding Font To A CSS Page
I have a font I downloa开发者_如何学编程ded and I'm trying to apply that font to my site.
so I simply used font-family but my font isn't there(obviously) any idea on how to add it?
You have to embed the font via CSS before you can use it (since most computers probably don't have the font installed locally). Check out:
CSS Cross Browser Fonts using CSS3 @font-face
The cross-browser compatible code ends up looking something like:
@font-face
{
font-family: "Your Font Name";
src: url(~/Fonts/SomeFontName.eot); /* IE */
src: local("The Real Font Name"),
url(~/Fonts/FontFileName.ttf) format("truetype"); /* non-IE */
}
body
{
font-family:"Your Font Name", verdana, helvetica, sans-serif;
}
You simply write the name of the font, such as:
font-family: Gotham;
.. or ...
font-family: "Myriad Pro";
It will work on your machine but not on users' machines unless they have the font installed.
I think the question is how can users of your site see the new font? Try this out: http://www.howtoplaza.com/how-to-use-custom-fonts-on-your-website-with-css
Such as this:
@font-face {
font-family: cool_font;
src: url('cool_font.ttf');
}
精彩评论