分配一个以字母结尾的CSS fontFamily [英] assigning a CSS fontFamily ending with a number
本文介绍了分配一个以字母结尾的CSS fontFamily的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以似乎如果我分配一个以数字结尾的字体,它不粘。
so it seems that if I assign a font family ending with a number it doesn't stick
a = document.createElement("div")
a.style.fontFamily = "Arial"
是
<div style="font-family: Arial; "></div>
但
a = document.createElement("div")
a.style.fontFamily = "Goudy Bookletter 1911"
然后a
<div></div>
我确定它的结尾数是问题。自
I'm pretty sure its the ending number that is the problem. Since
a = document.createElement("div")
a.style.fontFamily = "Goudy Bookletter blablabla"
,a则为
<div style="font-family: 'Goudy Bookletter blablabla'; "></div>
这是一个错误?我在chrome 16中这样做
Is this a bug? I'm doing this in chrome 16
推荐答案
设置font-family时,空格和数字的问题会导致问题。用单引号将font-family名包含在Chrome 16中。
Something about the spaces and numbers causes a problem when setting font-family. Enclosing the font-family name in single quotes allowed it to work in Chrome 16 for me.
a.style.fontFamily = "'Goudy Bookletter 12'";
没有引号,我看到了以下奇怪行为
Without the quotes I saw the following odd behavior
a.style.fontFamily = "Goudy Bookletter12"; //works
a.style.fontFamily = "Goudy 12Bookletter"; //works
a.style.fontFamily = "Goudy 12 Bookletter"; //does not work
这篇关于分配一个以字母结尾的CSS fontFamily的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文