问题描述
我在使用某些CSS时遇到问题。
目前我使用@fontface它工作正常和dandy。
然而,对于没有我实现其他字体的时候,我想读取,但我想对它们的样式有点不同。
例如,如果显示Rockwell,我想将font-weight设置为bold。但不是如果它是时代新罗马。
此外,我只喜欢letter-spacing:-4px;
I'm having trouble with some CSS.Currently I'm using @fontface which works fine and dandy.However for the times that it doesn't I have implemented other fonts to be read however I'd like to style them all a bit differently.For an example, if Rockwell is displayed I'd like the font-weight to be set to bold. But not if it is Times New Roman.Furthermore, I'd only like the "letter-spacing: -4px;" to apply if Times New Roman is being displayed.
这是可能吗?如果是,请协助一些代码。
Is this even possible? And if so, please assist with some code.
h1{ font: 88px 'Chunkfive', Rockwell, Times New Roman, Georgia; letter-spacing: -4px; }
h1 span{ font: 88px Times New Roman, Georgia, serif; letter-spacing: -4px; }
推荐答案
。
我不认为有一个直接的解决方案,但在某些情况下你可以使用这种解决方法。
I do not think there is a direct solution, however in some cases you can use this workaround.
- 嵌入字体。
- 检测是否成功(http://www.lalit.org/lab/javascript-css-font-detect/)
- 如果是/否添加到
< html>
class =fontName
属性。 - 在CSS中添加特殊声明,如
.fontName body {font-weight:bold; }
- 准备好意味着很多工作。特别是使用粗体 - 请记住< strong>
如何。 - 祝你好运;)
- Embed font.
- Detect if you succeed (http://www.lalit.org/lab/javascript-css-font-detect/)
- If yes/no add to
<html>
class="fontName"
attribute. - In CSS add special declarations, like
.fontName body { font-weight:bold; }
- be prepared it means a lot of work. Especially with bolding - keep in mind how does<strong>
will look like. - Good luck ;)
每个解决方法都有一些问题,例如JS可用性等等。也许它会为你工作。
As every workaround it has some issues - like JS availability and so on. Maybe it will work for you.
这篇关于使用@fontface,如何对不同的字体族应用不同的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!