Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    26
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Expanding div BG?

    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/walla...inventory.html
    Last edited by bigblondehead; 12-22-2010 at 09:02 PM.

  • #2
    New Coder
    Join Date
    Jul 2010
    Posts
    26
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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!

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,694
    Thanks
    22
    Thanked 1,832 Times in 1,816 Posts
    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 -
    Code:
    <!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>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    bigblondehead (12-27-2010)

  • #4
    New Coder
    Join Date
    Jul 2010
    Posts
    26
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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?

  • #5
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,694
    Thanks
    22
    Thanked 1,832 Times in 1,816 Posts
    Quote Originally Posted by bigblondehead View Post
    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 -
    Code:
    <!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>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •