简体   繁体   English

如何使用CSS或Javascript或jQuery使粗体字体变薄?

[英]How to make the bold font getting thin, using CSS or Javascript or jQuery?

If I am using a font and don't have the bold version, I could use the tag text-shadow , adding a contour to make the thin font bolder. 如果我使用的是字体并且没有粗体版本,我可以使用标签text-shadow ,添加轮廓以使细字体变粗。

But I have only the bold font, and I want to make it thinner. 但我只有粗体字,我想让它更薄。 I don't know what CSS or Javascript or jQuery script to use. 我不知道要使用什么CSS或Javascript或jQuery脚本。

Is it possible to make a bold font thinner using CSS, Javascript or jQuery? 是否可以使用CSS,Javascript或jQuery使粗体字体变薄? How? 怎么样?

You cannot make a font thinner. 你不能使字体更薄。 Even making it bolder with text-shadow is not real: it produces a distorted presentation of the font, not a bolder font. 即使使用text-shadow更大胆也不是真实的:它会产生扭曲的字体呈现,而不是更大胆的字体。

So you should select your font family according to your intentions of using different typefaces (including different weights) and the availability of typefaces in each font family. 因此,您应根据您使用不同字体(包括不同重量)的意图以及每个字体系列中字体的可用性来选择字体系列。

Browsers could implement font-weight values smaller than 400 in the same manner as some browsers implement some values larger than 400 when no bold typeface is available, namely by algorithmically changing the widths thicker. 浏览器可以实现小于400的font-weight值,其方式与某些浏览器在没有粗体字体时实现大于400的值相同,即通过算法更改宽度更粗。 But no browser seems to do that. 但是没有浏览器似乎这样做。

Though late 虽然迟到了
To make font thinner, add 要使字体更薄,请添加

    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic">

in the head section then style your text 然后在头部区域设置文本样式

style = "font-family: Lato;
          font-weight:100 or 200 or 300... (according to the thinness you want);
          font-size: ...;"

With font lato, you can achieve the thickness if font you want and its tested in all browsers. 使用font lato,您可以获得所需的字体厚度,并在所有浏览器中进行测试。
Check these fonts here 在这里检查这些字体
It worked perfectly for me. 它对我来说很完美。

While browsers can generate bold versions, I am not aware they can do the reverse process. 虽然浏览器可以生成粗体版本,但我不知道它们可以执行相反的过程。 To a very rough approximation, you can generate text that is both lighter and narrower using transform : 对于非常粗略的近似,您可以使用transform生成更轻和更窄的文本:

<div style="transform: scaleX(0.8);transform-origin:center left">This might very well appear lighter./div>

but that is a very crude hack at best and requires eyeballing the scale value for every font. 但这是一个非常粗糙的黑客,需要注意每种字体的比例值。

Do you mean the CSS font-weight Property? 你的意思是CSS font-weight属性? You can refer how to use the property here. 您可以在这里参考如何使用该属性。 http://www.w3schools.com/cssref/pr_font_weight.asp http://www.w3schools.com/cssref/pr_font_weight.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM