Does anyone know how to make a surrounding div the width of the inner text?
I know i can set the div to display: inline-block; but this only works when your inner text is one line. Whenever the text is too big as the set max-width, the text starts on a second line and the width of the div is set as the max-width.
Even if there appears empty space now.
On this image, i want to apply this to the title with the pink transparent background.
https://img.skitch.com/20120206-e912tg8nwnrrbm5qqhxrb789qk.jpg
Many thanks!
Tom
My solution:
As i can’t change the markup easily, the jquery solution did the trick indeed.
This is what i did:
$('#something h2').each(function(index) {
$(this).css('width',$(this).find('a').css('width'));
});
Have you tried setting it using jQuery?
$('#UrDIV').css('width',$('#UrPText'))Maybe this will work for you.