Jump to content

One div, three backgrounds, one that repeats


shiny_spoon

Recommended Posts

Hey guys,

 

I could use a hand making this container box I'm working on. Its got three parts, we'll call them top.gif, mid.gif and bot.gif. I am trying to create a box where top.gif, and bot.gif are static and do not repeat, but mid.gif repeats Y as more content appears in the box. The catch is text has to be inside the entire container, and not just in the mid section.

 

+------------------------------------+
| top.gif     beginning of paragraph |
+------------------------------------+
|             middle of paragraph    |
| mid.gif     middle of paragraph    |
|             middle of paragraph    |
+------------------------------------+
| bot.gif     end of paragraph       |
+------------------------------------+

 

I've tried a bunch of things including using <img> tags for the top and bottom images, but nothing seems to work out the way I want it to. Note that top.gif and bot.gif have curved corners, so having mid.gif repeat from top to bottom behind them is out of the question, unfortunately. :-[

 

Any advice?

 

Thanks!

Link to comment
Share on other sites

Actually...you could do it one way...

 

<div style="background:url(mid.gif) repeat-y;width:400px;">
  <div style="background:url(top.gif) no-repeat;">
    <p style="padding:0;margin:0;background:url(bot.gif) no-repeat left bottom;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In in tellus justo. Fusce porttitor ipsum eget lorem sagittis pulvinar. Aenean congue massa interdum sem facilisis nec posuere lacus tristique. Sed vel leo mi, non consequat odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras condimentum lorem sit amet urna posuere et vestibulum nibh porttitor. Vivamus at convallis neque. Morbi a elit lectus, ac suscipit tortor. Quisque id leo id erat pellentesque scelerisque. Aenean tincidunt lorem eget erat hendrerit auctor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut iaculis ultricies nisl at egestas.</p>
  </div>
</div>

 

the padding/margin is only there to show you it fills to the edges

Link to comment
Share on other sites

Hmm... It looks like it wants to work, but all three backgrounds just pile on top of each other at the top of the div.

 

Thanks though! I'll tinker around with this and see if I can get a result out of it.

 

Edit: I actually got it working by tinkering around with heights. Now my only problem is that the mid.gif appears through the corners of top.gif and bot.gif because they have transparencies. There's no way I can tell the middle element to start after x pixels and stop before y pixels, is there? I could always set a static background color so it doesn't show, but that would limit my layout a bit.

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.