CSS non-wrapping floating divs

后端 未结 4 1981
抹茶落季
抹茶落季 2020-12-08 03:51

I need to create a single line containing a variable amount of (floating?) divs: the container dimension is fixed, and it is supposed to add an horizontal scrollbar when nee

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 04:18

    Use display: inline-block instead of floatand give the container white-space: nowrap.

    div#sub > div#ranking {
        position:relative;
        top:42px;
        left:7px;
        width:722px;
        height:125px;
        overflow-x:auto;
        overflow-y:hidden;
        white-space: nowrap;
    }
    div#sub > div#ranking > div.player {
        display: inline-block;
        width:67px;
        height:120px;
        margin-left:5px;
        background-color:#f3e1bb;
    }
    

    Here an example: http://jsfiddle.net/D5hUu/3/

提交回复
热议问题