Understanding issue with CSS width property

Discussion in 'CSS' started by xtheunknown0, Jul 19, 2010.

  1. #1
    In side a wrap div of width 800px, I have a sidebar div with the following code:

    float:left;
    width:50%;
    background-color:white;
    font-size:1em;
    position:fixed;

    The sidebar won't take up 50% of the wrap (400px) but 50% of the browser window (1350px). *Why?*

    The div called main sits next to the sidebar on the right with width 50% and it is around 400 px.
     
    xtheunknown0, Jul 19, 2010 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Probably because of {position: fixed;}. Its containing block is the viewport.

    cheers,

    gary
     
    kk5st, Jul 20, 2010 IP
  3. xtheunknown0

    xtheunknown0 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That's it!

    Thank you very much.
     
    xtheunknown0, Jul 20, 2010 IP