CSS Positioning Question

Discussion in 'CSS' started by drywallinfoman, Mar 26, 2008.

  1. #1
    I have a site with a top section and main section within a container. The top section has a banner within it. In my main section, I have a background that consists of a horizontal white bar with a stripe on each side, thus creating a border. I have 15 px of padding on left and right. I would like to add a bottom section that connects up with the main section, creating the bottom border. I know how to do this with absolute positioning and a set height in my main section, but I dislike this method since this restricts the amount of content. If I place a div within my main section, it obeys the 15 px padding and does not extend to the right and left edges. Is there a way to position a bottom section that contains my bottom border so it connects up with the main section background? A picture to help explain what I am trying to do is shown here:
    [​IMG]
    Thanks for any help you can provide.

    #Container {
    	position: relative;
    	margin-left: auto;
    	margin-right: auto;
    	width: 730px;
    	
    	}
    
    #top {
    	position: absolute;
    	top: 0px;
    	left: 0px;
    	width: 730px;
    	margin: 0px 0px 0px 0px;
    	height: 75px;
    	padding: 0px 0px 0px 0px;
    	background-image: url(images/banner.png);
    	} 
    
    #maincontent {
    	position: absolute;
    	top: 75px;
    	left: 0px;
    	width: 700px;
    	padding: 0px 15px 0px 15px;
    	
    	margin: 0px 0px 0px 0px;
    	background-image: url(images/background.PNG);
    	}
    HTML:
     

    Attached Files:

    drywallinfoman, Mar 26, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    Easiest way to do it would to be to put a div after the content section with padding/margin/everything at 0. And make sure the bottom margin on the content div is 0 and let it ride up under it. Have to give it height, width, set the left/right margin to auto.
     
    shallowink, Mar 26, 2008 IP
  3. drywallinfoman

    drywallinfoman Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks! How should I position this?
     
    drywallinfoman, Mar 26, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #4
    Just put it as relative with margin:0 auto; padding:0 and the image as the background. Set the width to the img size etc.
     
    shallowink, Mar 26, 2008 IP
  5. drywallinfoman

    drywallinfoman Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I got it to work! I placed the bottom div within the main content div at the bottom with CSS

    #bottom {
    	width: 730px;
    	height: 21px;
    	padding: 0px 0px 0px 0px;
    	margin: 0px 0px 0px 0px;
    	background-image: url(images/bottomline.PNG);
    	position:relative;
        left:-15px;
    	}
    HTML:
    The relative positioning shoved it over to the far left and the image extended to the far right.
     
    drywallinfoman, Mar 26, 2008 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    cool. it should work no matter how much content you put in there now.
     
    shallowink, Mar 26, 2008 IP
  7. drywallinfoman

    drywallinfoman Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for the help! Hope this thread can help others as well.
     
    drywallinfoman, Mar 27, 2008 IP