I have a design I want to implement that involves title text appearing with its own background color, padded by 10px, over an image, par example:
http://i.stack.imgur.com/E7EpS.png
The first example in this picture works well, and is simple:
.greenbox {width:520px; height:261px; position:relative;}
.greenbox span { padding:0 10px; background:#000; position:absolute; left:0; bottom:40px; }
Trouble arises when the text overflows onto another line, then the span elements padding does not effect the text on the line breaks, it renders like so:
http://i.stack.imgur.com/pY18f.png
Anyone know of an alternative, or how they would set this design out so that the background color & padding was consistent?
Thanks in advance
Edit: I had simplified the code to make it concise, but had missed a vital part. Actually it's like this:
.greenbox {width:520px; height:261px; position:relative;}
.greenbox a {position:absolute; left:0; bottom:40px; }
.greenbox span { padding:0 10px; background:#000; }
With the html as:
<div class="greenbox">
<a href="link"><span>The Title Goes Here</span></a>
</div>
Thus the span remains inline, wrapped in a absolute position anchor.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…