请有人用@font-face 帮我解决这个问题。我已经多次使用这种技术,但出于某种原因,我终生无法弄清楚为什么字体不呈现。
所以我在 Visual Studio 中有一个名为 Web.Ui.Store 的元素,其中包含两个重要的子目录。 1./Content/css/Typography.css 2./Content/font/UTILITY-webfont.eot (我有 FontSquirrel 提供的所有字体,但为了解释只是标记命名这个扩展。)
现在在 Typography.css 中我有这些代码行。
@font-face {
font-family: 'UtilityBoldCondensed';
src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot#iefix');
src: url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.eot?') format('embedded-opentype'),
url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.woff') format('woff'),
url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.ttf') format('truetype'),
url('file:///C:/dev/trunk/Source/Web.Ui.Store/Content/font/UTILITY-webfont.svg#UtilityBoldCondensed') format('svg');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'LeagueGothicRegular';
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot');
src: url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.eot?#iefix') format('embedded-opentype'),
url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.woff') format('woff'),
url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.ttf') format('truetype'),
url('C:\dev\trunk\Source\Web.Ui.Store\Content\font\League_Gothic-webfont.svg#LeagueGothicRegular') format('svg');
font-weight: normal;
font-style: normal;
}
.UtilityBoldCondensed { font-family: 'UtilityBoldCondensed', Arial, Sans-Serif; }
.LeagueGothicRegular { font-family: 'LeagueGothicRegular', Arial, Sans-Serif; }
我很困惑为什么我的“特殊”字体不会加载到我的元素中。我今天已经更改了很多次相对路径,但仍然无法渲染它。我已将问题缩小为文件位置的相对路径问题。有人可以帮助确定这是否正确。
最佳答案
正如我在谷歌的网络字体上看到的那样; @font-face 总是在 @media 屏幕内 {}...
检查一下:
http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic
关于css - Visual Studio 不呈现@font-face,可能是相对路径问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7152568/