How to get Floating DIVs inside fixed-width DIV to continue horizontally?

前端 未结 9 515
情歌与酒
情歌与酒 2020-12-02 12:43

I have a container DIV with a fixed height and width (275x1000px). In this DIV I want to put multiple floating DIVs each with a width of 300px, and have a horizontal (x-axi

9条回答
  •  醉梦人生
    2020-12-02 13:02

    Put the divs you want to scroll in a table like so:

    Cell 1 
    Cell 2 
    Cell 3 
    Cell 4 
    Cell 5 

    Edit: I tried 3 of these suggested solutions - they all work fine in Google Chrome - but the first one (container1) doesn't work in IE (go figure) - so the SPAN solution gets my vote :-) :

    
    
    
    

    Cell 1 
    Cell 2 
    Cell 3 
    Cell 4 
    Cell 5 

    Cell 1  Cell 2  Cell 3  Cell 4  Cell 5 

    Cell 1 
    Cell 2 
    Cell 3 
    Cell 4 
    Cell 5 

    Edit 2:

    I ran this test page through browsershots.org, to see how different browsers handle it. Conclusion: Browser compatibility sucks. :-)

    http://browsershots.org/http://dot-dash-dot.com/files/test_div2.htm

    The table solution worked more often - but the span option (which is cleaner) only broke on browsers I've never heard of. :-)

提交回复
热议问题