Jump to content

[SOLVED] Repeating Background Help


JustGotAQuestion

Recommended Posts

I need to repeat an image on the x axis behind some text so that no matter how long the text is, the background with be exactly as long. The text will be called in by a database, so it is variable in length. But, i can't have the image run off past the text (my current problem).

 

Here is that i have (doesn't work, runs off too far to the right).

 

<div style="background-image:url(images/repeat.png); background-repeat:repeat-x;">Some text of variable length.</div>

 

How can i limit the repeat to just where the text is? I can't just use width:whatever; because the text is variable in length.

Link to comment
https://forums.phpfreaks.com/topic/102254-solved-repeating-background-help/
Share on other sites

this is due to the block level nature of your elements.

 

text should really go in a p tag but lets stick to what you have...

 

If you add float: left to your div style then it will only take up as much space as it needs - instead of filling the horizontal space available...

Awesome, this was the type of fix i was looking for.

 

One thing though: i have noticed that floating works differently in IE and Firefox. I am not sure if it will in this case or not, but is there another solution that doesn't involve floating?

 

If not, no worries. This works fine, thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.