horizontal scrollbar for ul

前端 未结 5 698
忘了有多久
忘了有多久 2020-12-30 01:52

For some reason, I can\'t prevent the UL and it\'s LI\'s from wrapping. I want the UL\'s width to be exactly the width of the LI\'s on one line (without wrapping) and if the

5条回答
  •  梦谈多话
    2020-12-30 02:18

    Caveat: Untested

    Would you not just want to set a width for the li item

    div#nav ul li {    
       margin-right: 15px;     
       float: left;     
       font-size: 12px;     
       list-style-type: none;
       width: 100px;
    }
    

    And then set the width to a fixed width and overflow on the UL to scroll?

    div#nav ul {
        width: 800px;
        overflow: scroll;
    }   
    

    This would cause you UL to scroll when your li's went past say 8, is that what you're after?

提交回复
热议问题