@font-face and font-variant bad idea?

最后都变了- 提交于 2019-12-14 03:47:58

问题


if i use @font-face font and font-variant: small-caps for the same selector the font will fallback to the next system default font in safari. how do i get around that?


回答1:


I had some trouble creating an example to replicate your issue at first, which made me realize that font-face is not a standard CSS2 attribute; the equivalent is font-family. So I did some quick research on @font-face, and found that it's -- depending on how you look at it -- either a non-standard attribute specific to Firefox 3.5 or a part of the not-yet-mainstream CSS3. Safari has partial support for CSS3, depending on version, but I suspect that this is the cause of your undesired behavior.




回答2:


This was a WebKit bug. It’s been fixed, and Safari should be fine the next time it’s updated. The current version of Chrome is using a newer version of WebKit where the bug has been fixed. Here’s a good way to detect it (from SafariSmallCapsWebFontFix):

if ((navigator.userAgent.match(/WebKit\/([^.]+)/) || [] )[1] < 534) {
    // Broken, work around it!
}

You could use that JavaScript to, say, add a class to the html node and change how you style the page.




回答3:


Well i think its just a bug :( i now use :first-letter pseudo selector to achieve that



来源:https://stackoverflow.com/questions/2014392/font-face-and-font-variant-bad-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!