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

前端 未结 9 536
情歌与酒
情歌与酒 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:08

    #row {
        white-space: nowrap; /* important */
        overflow: auto;
    }
    
    .items {
        display: inline-block;
    }
    item 1
    item 2
    item 3
    item 4
    item 5
    item 6
    item 7
    item 8
    item 9
    item 10

    The trick here is the "white-space: nowrap" property of the parent which simply tells all it's child elements to continue horizontally and the "display: inline-block" property of it's children. You don't need to add any other property to make this work.

    JS Fiddle: http://jsfiddle.net/2c4jfetf/

提交回复
热议问题