in site bbcode text background and size output like this
<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://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
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
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size.
The span tag is just like a div, which is used to group similar content so it can all be styled together.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With