字体粗细无法正常工作?
http://www.i3physicals.com/blog/2010/07/dsfsdf/
这是一个例子。
写着“PHP”的部分(右上角)仍然像以前一样纤细。 CSS代码的一部分,但在FF下不起作用。
.wp_syntax_lang {
background-color:#3c3c3c;
position:absolute;
right:0;
padding:1px 10px 3px;
color:#ddd; font-size:9px; font-weight:800;
text-transform:uppercase;
-moz-border-radius-bottomleft:5px;
-webkit-border-bottom-left-radius:5px;
border-radius-bottomleft:5px;
}
这是我尝试过bold、bolder、700、800、900的
http://www.i3physics.com/blog/2010/07/dsfsdf/
Here is an example.
The part where it said "PHP" (the right top corner) remained as slim as it was.
here is part of the css code
.wp_syntax_lang {
background-color:#3c3c3c;
position:absolute;
right:0;
padding:1px 10px 3px;
color:#ddd; font-size:9px; font-weight:800;
text-transform:uppercase;
-moz-border-radius-bottomleft:5px;
-webkit-border-bottom-left-radius:5px;
border-radius-bottomleft:5px;
}
I tried bold, bolder, 700, 800, 900 and is not working under FF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您使用的字体不存在这些粗细,则
font-weight
可能无法工作 - 在嵌入自定义字体时您经常会遇到此问题。在这些情况下,浏览器可能会将数字四舍五入到其可用的最接近的权重。例如,如果我嵌入以下字体...
那么我将无法使用除 400 粗细之外的任何内容。所有其他粗细将恢复为 400。
如果您想要额外的粗细,则需要在单独的 < code>@font-face 声明带有这些额外的权重,就像这样。
通常,每种粗细都有一个浏览器需要下载的单独字体文件,除非您使用可变宽度字体。
font-weight
can fail to work if the font you are using does not have those weights in existence – you will often hit this when embedding custom fonts. In those cases the browser will likely round the number to the closest weight that it does have available.For example, if I embed the following font...
Then I will not be able to use anything other than a weight of 400. All other weights will revert to 400.
If you want additional weights, you need to specify them in separate
@font-face
declarations with those additional weights, like this.Usually each weight will have a separate font file the browser will need to download, unless you're using variable width fonts.
这是因为字体大小(9px)太小,无法显示粗体。尝试 11px 或更大,效果很好。
Its because the font size (9px) is too small to display bold. Try 11px or more and it works fine.
大多数浏览器不完全支持
font-weight
的数值。 这是一篇关于这个问题的好文章,尽管它有点老了,但它似乎确实是正确的。如果您需要更粗的字体,那么您可能需要尝试使用比现有字体更粗的其他字体。当然,您可以调整字体大小以获得类似的效果。
Most browsers don't fully support the numerical values for
font-weight
. Here's a good article about the problem, and even tough it's a little old, it does seem to be correct.If you need something bolder then you might want to try using a different font that's bolder than your existing one. Naturally, you could probably adjust the font size for a similar effect.
如果您要导入 Google 字体,则需要确保已指定要使用的所有粗细。
就我而言,我使用的是 Google 的 Roboto 字体。我必须使用几个不同的权重导入它,如下所示:
请记住,每个额外的权重都会增加每个访问者需要下载的数据量,并且可能会减慢页面的加载速度,因此仅使用必要的权重。
If you're importing a Google font, you need to ensure you've specified all the weights that you would like to use.
In my case, I was using Google's Roboto font. I had to import it with several different weights, like this:
Remember that each additional weight increases the amount of data each visitor needs to download, and can slow down the loading of your page, so only use what's necessary.
我也面临着同样的问题,我通过选择我正在使用的谷歌字体后解决了这个问题,然后我单击(家庭选择)最小化选项卡,然后单击“自定义”按钮。
然后我选择了我想要的字体粗细,然后将更新的链接嵌入到我的 html 中。
i was also facing the same issue, I resolved it by after selecting the Google's font that i was using, then I clicked on (Family-Selected) minimized tab and then clicked on "CUSTOMIZE" button.
Then I selected the font weights that I want and then embedded the updated link in my html..
我删除了
text-transform: uppercase;
,然后将其设置为bold
/bolder
,这似乎有效。I removed the
text-transform: uppercase;
and then set it tobold
/bolder
, and this seemed to work.对我来说,当我将字体样式从
font-family: 'Open Sans', sans-serif;
更改为Arial
时,这是一项大胆的工作For me the bold work when I change the font style from
font-family: 'Open Sans', sans-serif;
toArial