...

View Full Version : Expanding div BG?



bigblondehead
12-22-2010, 06:22 PM
Hi I am building an ecommerce site, and would like the background image to expand/contract as new items are added. I have divided the background into 3 divs, and would just like the middle to expand. Right now it definitely does not. Does anyone know what I've done wrong? Thanks! The page is at:

http://www.marcata.net/walkmen/wallaboutbayantiques/inventory.html

bigblondehead
12-26-2010, 07:32 PM
Anyone have an idea on this? I used a table because I didn't know how to align it with strictly divs, but I'm definitely not married to the table!

Excavator
12-26-2010, 07:56 PM
Hello bigblondehead,
Yes, tables are not the way to go here. See the link about tables in my sig.

Typically you would have a middle div with no height specified so it could expand to contain whatever you put in it. Make that background of that div repeat-y so the background image will be the same height as your content.

Something like this -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin: 0;
background: #FC6;
}
#middle {
height: 1500px; /*for demo only*/
width: 950px;
margin: 30px auto;
background: url(http://www.marcata.net/walkmen/wallaboutbayantiques/images/inventory_bg_middle.gif) repeat-y;
}
</style>
</head>
<body>
<div id="middle">
<!--end middle--></div>
</body>
</html>

bigblondehead
12-27-2010, 01:20 AM
Thanks a lot. That seems to work in terms of having the background repeat, but I have a "bottom" div that holds the bottom part of the image. How would you line that up to the bottom of the middle div, if the middle div is expanding and contracting with added/removed content?

Excavator
12-27-2010, 03:18 AM
Thanks a lot. That seems to work in terms of having the background repeat, but I have a "bottom" div that holds the bottom part of the image. How would you line that up to the bottom of the middle div, if the middle div is expanding and contracting with added/removed content?

You might want images that repeat better than yours since yours don't quite line up.
Look at this though -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin: 0;
background: #FC6;
}
#container {
width: 950px;
margin: 30px auto;
}
#header {
height: 312px;
background: url(http://www.marcata.net/walkmen/wallaboutbayantiques/images/inventory_bg_top.gif);
}
#middle {
height: 1500px; /*for demo only*/
background: #999 url(http://www.marcata.net/walkmen/wallaboutbayantiques/images/inventory_bg_middle.gif) repeat-y;
overflow: auto;
}
#footer {
height: 134px;
background: url(http://www.marcata.net/walkmen/wallaboutbayantiques/images/inventory_bg_bottom.gif);
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<!--end header--></div>
<div id="middle">
<!--end middle--></div>
<div id="footer">
<!--end footer--></div>
<!--end container--></div>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum