相当于“字体大小+2”的 HTML 样式标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9458157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:47:55  来源:igfitidea点击:

HTML Style tag equivalent of "font size+2"

htmlcssstylesstylesheet

提问by NealWalters

What is the new "style" way of temporary increasing a font size, and then returning back to the normal (without using CSS, or is CSS the better way?).

临时增加字体大小然后恢复正常的新“样式”方式是什么(不使用 CSS,还是 CSS 更好?)。

I want to insert a Hebrew word in my text, and for beginners, the Hebrew font is just too small. I always want it bigger than the current font size, not pegged to some specific size.

我想在我的文本中插入一个希伯来语单词,对于初学者来说,希伯来语字体太小了。我总是希望它大于当前字体大小,而不是固定到某个特定大小。

Line 1 below works (the old way of doing things). What is the fix to line 2?

下面的第 1 行有效(旧的做事方式)。对第 2 行的修复是什么?

This is normal.  <font size="+2">bigger</font> back to norm. 
<span style='{FONT-SIZE: +2}'> and also bigger</span>.

采纳答案by Will

CSS is the better way to do this.

CSS 是更好的方式来做到这一点。

<span style="font-size: 120%;"></span>

<span style="font-size: 120%;"></span>

回答by j08691

I would create a class (let's say .hebrew) and set the font-size property to 1.2em. This way whatever the font size is of the surrounding text, the text with the class of hebrew will be 20% larger.

我会创建一个类(假设是 .hebrew)并将 font-size 属性设置为 1.2em。这样,无论周围文本的字体大小如何,希伯来语类的文本都会大 20%。

.hebrew {
    font-size: 1.2em;
}

Here's a quick demo jsFiddleto illustrate (colored with green to help show the difference).

这是一个快速演示 jsFiddle来说明(用绿色着色以帮助显示差异)。

And as noted in the comments, to use this in your HTML you would add the class like so:

正如评论中所指出的,要在 HTML 中使用它,您可以像这样添加类:

<span class="hebrew"> malesuada augue imperdiet eget. Cum et magnis</span>

回答by Alexander Pavlov

<font size="+2">is equivalent to font-size: x-large;so your second line should be

<font size="+2">相当于font-size: x-large;所以你的第二行应该是

<span style='font-size: x-large;'> and also bigger</span>.