Wrap floating DIVS
I have 3 divs and all of them are 开发者_运维知识库floated to the left. My container can accommodate only 2(intentional) so the 3rd div is pushed below. My problem is the height of 2nd div is more than the other two, and the third div is showing up where 2nd div ends, leaving an empty space between 1st and the 3rd div. I want the 3rd div to wrap around the 2nd div, so that it shows up right below 1st.
I have tried floating the second to the right, and seems like it works, but I wanted to know if there is solution floating all of them to the left.
Just to clarify I have added an image showing the problem below:
http://img684.imageshack.us/img684/3209/divs.png
For a simple fix, you can wrap the same element around div1 and div3, assign a width and float left, assign a width to div2 and float it left as well.. assuming source order doesn't matter.
Won't making div1 wider (the same width as div3) solve this?
If you know the exact heights of the divs, you could use a negative top-margin on div3 to bring it up.
#div3 {
top-margin: -100px;
}
(replace '100px' with the difference between div1's height and div2's height)
精彩评论