Reputation: 2098
Is is possible to align a background image according to where the text ends?
Demo code:
.textBox .text { padding-top: 8px; background: url('../images/text-top.gif') left top no-repeat; padding-right:15px; }
.textBox .bottom { padding: 0px 0px 20px 15px; background: url('../images/text-bottom.gif') right bottom no-repeat; }
<div class="textBox">
<div class="text">
<div class="bottom">blah blah blah multi-line text here</div>
</div>
</div>
What i want to accomplish is the ../images/text-bottom.gif to be aligned at the end of the text.
Upvotes: 0
Views: 1106
Reputation: 2098
no, simple display inline didn;t work. yet i found a solution
i place the final word in a [span] tag, all text in [p] tag and modify my css as follow:
.textBox .bottom { padding: 0px 0px 20px 15px; }
.textBox p { padding-bottom: 21px; font-size: 14px; line-height: 21px; color: #666; position:relative; }
.textBox .bottom p span{ background: url('../images/text-bottom.gif') top right no-repeat; width:auto; padding-left:5px; padding-right:15px;height:40px; display: inline;
Using regular expression, i find the last word of my text, and i enclose it in [span] and it works like i want
Upvotes: 0