gpt4 book ai didi

asp.net - 在网页中嵌入字体

转载 作者:技术小花猫 更新时间:2023-10-29 11:17:25 25 4
gpt4 key购买 nike

我在谷歌上搜索了很多,试图找出如何在网页上嵌入字体。据我了解,您应该以 .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');
}
}

首先我是这样调用它的

<head runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

我试着像这样使用它

<asp:Label ID="lbl" runat="server" Font-Bold="True" 
Font-Size="30pt" Text="TEST123" CssClass="MyStyle"></asp:Label>

但无论我使用 ie8 还是 chrome2,字体都没有改变。

如果我明白http://randsco.com/?p=680&more=1&c=1更正它应该是可能的

如果我在 ie8 中打开源代码,我应该能够看到字体名称吗?因为如果我通过 ie8 代码搜索 king,我什么也找不到

最佳答案

为了使嵌入式字体功能起作用(在支持它的浏览器中),您还必须将新的字体系列应用于样式选择器。

例如

h1 { 
@font-face {
font-family: CustomFont;
src: url('CustomFont.ttf');
}
}

不会成功,即使它确实会加载字体(如果它是一个有效的 URL)——因为我们所做的一切就是加载字体。我们仍然需要实际应用它,所以

@font-face {
font-family: CustomFont;
src: url('CustomFont.ttf');
}

h1 {
font-family: CustomFont;
}

两者都加载自定义字体并将其应用于您的 CSS 选择器(在本例中为 h1)。

你几乎肯定会想要阅读关于@font-face 的教程(Krule 已经在上面推荐了一个很好的教程,其中包含指向可以与之一起使用的免费字体的链接。)同上所有关于优雅退化的警告,因为这仍然不是普遍支持的功能。

关于asp.net - 在网页中嵌入字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1382886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com