Scrolling DIV

Discussion in 'CSS' started by movieguy, Sep 15, 2010.

  1. #1
    Hello,

    I need a square div area that needs to scroll with the user when the user scrolls down so that the div area is always at the same position of the screen (bottom left) no matter where the user is.
    Can this be accomplished using CSS only or does it require some javascript ??

    If so, could you perhaps enlighten me on how to accomplish this?
    Thanks !!
     
    movieguy, Sep 15, 2010 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    This is certaintly possible with CSS, via the use of fixed positioning. This enables the DIV to be fixed on the browser window regardless of whether the user is scrolling or not. Just add position:fixed; to the DIV to ensure it stays stuck, and then give it top: right: bottom: and left: attributes to position it where you want on the screen.

    For example:
    
    #myFixedDIV{
    position:fixed;
    bottom:0;
    left:0;
    width:200px;
    height:200px;
    background:grey;
    }
    
    Code (markup):
    Creates a 200px square DIV fixed on the bottom left of the screen.

    However as per usual I don't think this works in IE6 due to poor support ! I wouldn't worry about this though, although i'm sure there are fixes out there e.g see the link but I think they come with their own problems.
     
    Last edited: Sep 15, 2010
    wd_2k6, Sep 15, 2010 IP
  3. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Maybe you need a z-index to have your fixed div above other content.
     
    CSM, Sep 17, 2010 IP
  4. Rimona

    Rimona Active Member

    Messages:
    123
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    63
    #4
    Rimona, Sep 19, 2010 IP