简体   繁体   English

<span>字体大小的背景</span>

[英]<span> background with font size

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 如果我使span内联块,则背景色将位于整个框上

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生成的代码,用户有时会在文本大小之前选择背景色

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/

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

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