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 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tricky Background Stretch

    I have a page with a tiled background and then a container DIV with a semi-transparent PNG for a background that is bigger at the top and at the bottom, but thinner in the middle. I want to make it so that the middle of this background will stretch if the content within the container div gets too long. I have no idea how to achieve this. I have uploaded an attachment with an example that I hope is somewhat clear.

    If anyone could point me in the right direction or show me an example that does this, I would very much appreciate it!

    Thanks,

    Brandon
    Attached Thumbnails Attached Thumbnails Tricky Background Stretch-help.gif  

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,668
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello baasan,
    Probably a pretty easy fix... but we need to see your code.
    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

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I didn't have any code as I'm not sure what to try in order to solve the problem. I created this as a working example:

    http://ohmedia.ca/bgstretch/

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,668
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello again baaan,
    Kind of hard to visualize what you're trying to do. Did you really want the top and bottom sections jogged over like they are in the link or are you trying to make it look like the picture in your first post.

    Once you decide on what kind of image your going to use, you can just repeat it on the y-axis all the way down whatever div you want. Here's an example:
    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>
    <meta name="" content="authored by http://nopeople.com/Design" />
    <style type="text/css">
    html, body {
    	background: url(http://ohmedia.ca/bgstretch/bg.gif);	
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #container {
    	width: 563px;
    	/*height: 376px; remove height so container can expand with content*/
    		margin: 25px auto; /*pushes container down 25px and centers it*/
    	background: url(http://ohmedia.ca/bgstretch/containerbg.png) repeat-y;
    	}
    	
    	#innercontainer {
    		width: 300px;
    		margin: 0 auto; /*centers innercontainer*/
    		line-height: 26px;
    	}
    </style>
    </head>
    <body>
        <div id="container">    	
            <div id="innercontainer">
            	<p>
                	I want the narrower part of the background of #container to stretch if this text takes up 
                    enough space. 
              	</p>
        <p>
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna 
            aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 
            sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
            nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo 
            duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna 
            aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 
            sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
            nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo 
            duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </p>
    <!--end innercontainer--></div>    
    <!--end container--></div>
    </body>
    </html>
    If you want rounded corners there are a few different methods. Here's a couple different examples:
    one
    two

    To see how those are done just click View Source in your browser.
    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
    •