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
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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.