make a single row of divs with horizontal scroll bars

前端 未结 4 1910
[愿得一人]
[愿得一人] 2021-02-06 04:18

Ok so I thought I had this fixed using white-space:no-wrap it worked in chrome but nothing else.

I have something like this:

相关标签:
4条回答
  • 2021-02-06 05:00

    You need to set you div.inner width to something absolute like 64px and the make your lis float to either right or left and then set the overflow-x property of your parent div to auto. check this fiddle

    0 讨论(0)
  • 2021-02-06 05:12

    You need to put one massive horizontal div inside the parent div with overflow: auto; This will allow the to float left without wrapping to the next line, and it will only scroll when the boundary of the parent div is crossed.

    0 讨论(0)
  • 2021-02-06 05:15

    Write like this:

    .outer{
        width:400px;
        overflow:auto;
        white-space:nowrap;
    }
    .outer li{
        display: inline-block;
        *display: inline;/*For IE7*/
        *zoom:1;/*For IE7*/
        vertical-align:top;
        width:40px;
        margin-right:20px;
        background:red;
        white-space:normal;
    }
    

    Check this http://jsfiddle.net/ZrpHv/

    0 讨论(0)
  • 2021-02-06 05:18

    Well I know every good and purist webdeveloper will hate me (and I hate me when I post something like that) but you can simply use table to do that.

    this runs in all browsers. Yes, it is not standard, no it is not CSS. But... productivity is sometime better than standard.

    You could also used a fixed div width for your container (ul). and use float left position for all your children

    0 讨论(0)
提交回复
热议问题