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

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

    You need an extra div with a large width to contain the blocks, then they will extend wider than the container div and not drop down to a new line.

    The HTML:

    The CSS:

    #container {
        height: 275px;
        width: 1000px;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: 275px;
    }
    #container #width {
        width:2000px; /* make this the width you need for x number of blocks */
    }
    #container div.block {
        float: left;
        margin: 3px 90px 0 3px;
    }
    

提交回复
热议问题