php <span> 背景字体大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20430567/
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-25 03:11:34  来源:igfitidea点击:

<span> background with font size

phpcssbackgroundfont-sizehtml

提问by user614963

in site bbcode text background and size output like this

在站点 bbcode 文本背景和大小输出这样

<span style="background: #ff0000;">

text size normal

<br></br>
<br></br>
<span style="font-size: 250%">

    text size big

</span>
<br></br>
<br></br>

</span>

the problem is background will not fit text size

问题是背景不适合文字大小

http://jsfiddle.net/fr3wA/

http://jsfiddle.net/fr3wA/

http://img11.imageshack.us/img11/7199/sdpm.png

http://img11.imageshack.us/img11/7199/sdpm.png

if I make the span inline block , the background color will be on the whole box

如果我制作跨度内联块,背景颜色将在整个框上

http://img31.imageshack.us/img31/323/d3t5.png

http://img31.imageshack.us/img31/323/d3t5.png

I know the background color will fit the text if I put the style in like this

我知道如果我像这样放置样式,背景颜色将适合文本

<span style="background: #ff0000;">

text size normal

<br></br>
<br></br>
<span style="style="background: #ff0000;"font-size: 250%">

    text size big

</span>
<br></br>
<br></br>

</span>

my problem is the code generated from php bbcode and the user sometime choose background color before text size

我的问题是从 php bbcode 生成的代码,用户有时在文本大小之前选择背景颜色

回答by Arian Faurtosh

Just inherit the background from the previous span

只需继承上一个跨度的背景

<span style="background: #ff0000;">

text size normal

<br /><br />
<br /><br />
<span style="font-size: 250%; background: inherit;"> <!-- inherit the background -->

    text size big

</span>
<br /><br />
<br /><br />

Check out how it works here: http://jsfiddle.net/fr3wA/3/

在这里查看它是如何工作的:http: //jsfiddle.net/fr3wA/3/