Cru*_*lIO 6 css asp.net fonts font-face
我用谷歌搜索了很多试图弄清楚如何在网页上嵌入字体.据我所知,您应该以.ttf和.eot格式将字体上传到您的网页.并在样式表中使用@ font-face.
我已将Kingthings_Italique.eot和Kingthings_Italique.ttf放在我的网页的根目录中.
创建这样的样式表.
.MyStyle
{
/* For IE */
@font-face
{
font-family: 'Kingthings Italique';
src: url('Kingthings_Italique.eot');
}
/* For Other Browsers */
@font-face
{
font-family: 'Kingthings Italique';
src: local('Kingthings Italique Regular'),
local('KingthingsItalique-Regular'),
url('Kingthings_Italique.ttf') format('truetype');
}
}
Run Code Online (Sandbox Code Playgroud)
首先,我这样称呼它
<head runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
我试着像这样使用它
<asp:Label ID="lbl" runat="server" Font-Bold="True"
Font-Size="30pt" Text="TEST123" CssClass="MyStyle"></asp:Label>
Run Code Online (Sandbox Code Playgroud)
但无论我使用ie8还是chrome2,字体都没有改变.
如果我理解http://randsco.com/?p=680&more=1&c=1正确,那么应该可以
如果我在ie8中打开源我应该能够看到字体名称吗?因为如果我通过ie8代码搜索国王,我什么也没发现
为了使嵌入字体功能起作用(在支持它的浏览器中),您还必须将新的字体系列应用于样式选择器.
例如
h1 {
@font-face {
font-family: CustomFont;
src: url('CustomFont.ttf');
}
}
Run Code Online (Sandbox Code Playgroud)
即使它确实会加载一个字体(如果它是一个有效的URL),也不会这样做 - 因为我们所做的只是加载字体.我们仍然需要实际应用它,所以
@font-face {
font-family: CustomFont;
src: url('CustomFont.ttf');
}
h1 {
font-family: CustomFont;
}
Run Code Online (Sandbox Code Playgroud)
加载自定义字体并将其应用于CSS选择器(在此示例中为h1).
你几乎肯定想读一个关于@ font-face的教程(Krule已经在上面建议了一个很好的链接到免费字体的链接,可以使用它.)同上面关于优雅退化的所有警告,因为这是仍然不是普遍支持的功能.