Container DIV's border won't stretch out of the window!

Discussion in 'CSS' started by 20footduck, Nov 8, 2005.

  1. #1
    Hi.

    I'm trying to achieve a fairly simple thing. I want my container div to have a border down its left and right sides. However when the content means the page stretches beyond the windows capacity the border disappears. It seems that the height of 100% does not refer to the content of the viewport, only to the window.

    Have spent the evening checking out 'nearlys' online, but not found a solution near enough. I'm sure there must be something simple I'm doing wrong! please enlighten me! take a look at the problem here:
    http://www.chrisslowe.uklinux.net/sofftest/variety.html

    thanks

    chris
     
    20footduck, Nov 8, 2005 IP
  2. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try putting the div inside another div with both set for height 100%

    or

    try floating it
     
    iShopHQ, Nov 8, 2005 IP
  3. 20footduck

    20footduck Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the 'div in div' solution results in the same thing:

    um..there was going to be a link here but i'm not allowed to until i've made over 10 posts...so take the address from my previous post (!) and replace 'variety.html' with 'test.html'

    not sure what you mean by floating it. I kinda get the floating for wrapping text around images, but not for general layout...?

    Any more info? thanks, chris
     
    20footduck, Nov 9, 2005 IP
  4. draculus

    draculus Peon

    Messages:
    63
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've looked at your test page. If you remove the position absolute from the inner div (layer2) and remove the height: 100% from both divs the page displays properly.
     
    draculus, Nov 9, 2005 IP
  5. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    iShopHQ, Nov 9, 2005 IP
  6. 20footduck

    20footduck Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks guys, but neither suggestion worked with the actual page i'm working on-variety.html (see my first post). draculus's works in the test page but because the content div, in variety.html, starts half way down the page removing position absolute shifts the content to the top of the page- not what i'm after. Setting the float of the content div to left,right,none,inherit doesn't have any effect... any more ideas?
    ta, chris
     
    20footduck, Nov 10, 2005 IP
  7. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm flat out of any that don't involve a hybrid CSS/HTML table solution
     
    iShopHQ, Nov 10, 2005 IP
  8. draculus

    draculus Peon

    Messages:
    63
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8

    Then I think your stuffed. I've had the same problem before. You can fix it on standards complient browsers, but not on IE.
     
    draculus, Nov 10, 2005 IP
  9. Arnica

    Arnica Peon

    Messages:
    320
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Looking at your page source all your content follows a normal sequence so you don't actually need to absolutely position anything. Just remove all the css you don't need eg position: & height: and let the page flow normally. You will need to float your logo and links <divs> accordingly. Your container <div> will then expand as you expect.

    The only time you would need to use position:absolute in a simple layout such as this would be to place your content areas before your navigation/header panel in the source while displaying in the correct order on screen.
     
    Arnica, Nov 10, 2005 IP
  10. 20footduck

    20footduck Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    thanks arnica! I read up on normal flow, got rid of the absolutes and height values and the border stretched the whole length of the content. However now the opposite of my original problem is true. if the content is not sufficient enough to reach the bottom of the page then the borders end to soon(which is why i had the container DIVs height as 100%). check out variety.html to see.

    What I want is a central column that has borders on its left and right edges, that reaches from the top to the bottom of the viewport, independent of whether the content. I'm sure its not that hard i must have seen it a thousand times...
     
    20footduck, Nov 11, 2005 IP
  11. FeelLikeANut

    FeelLikeANut Peon

    Messages:
    330
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Percentages refer to percent of the containing block. Everything will always have at least two containing blocks: the BODY element and the HTML element. Set both of those to 100% as well and that should fix the problem.
     
    FeelLikeANut, Nov 21, 2005 IP
  12. 20footduck

    20footduck Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    aha! thanks, i've got a much better understanding of how stylesheets flow. setting the relevant elements to 100% height, and removing the unnecessary positioning information (the absolute positioning and location of the top left corner) fixed it. thankyou all for your help.
    Chris
     
    20footduck, Jan 18, 2006 IP