0

How would I setup a div to be 100% of the parent div if it is floating?

Here are the two styles I've got, where sidebar is the child of container -

#container {
    width:1200px;
    margin-top:40px;
    overflow:hidden;
    text-align:center;
}
#sidebar {
    width:260px;
    float:left;
    overflow:hidden;
    height:1554px;
}
mskfisher
  • 3,291
  • 4
  • 35
  • 48
Matt
  • 5,005
  • 10
  • 32
  • 39

2 Answers2

0

I would do it with Javascript or better said jQuery. Have a look here: How do I keep multiple DIVs the same height using jQuery?

Community
  • 1
  • 1
Joseph
  • 9,171
  • 8
  • 41
  • 67
0

Elements that contain only floated children have a height that collapses to 0. So if you want to set the height of a child to 100% of the parent, you need to manually set the height on the parent.

kingjeffrey
  • 14,894
  • 6
  • 42
  • 47