overflow:hidden on inline-block adds height to parent

后端 未结 4 1896
长发绾君心
长发绾君心 2020-12-24 05:36

I\'m certain this has been asked before in some form or other, but I just can\'t find an answer..

I have some nested divs

4条回答
  •  长情又很酷
    2020-12-24 06:08

    I had this issue when building a horizontal slider. I fixed it with vertical-align:top on my inline-block elements.

    ul {
        overflow-x: scroll;
        overflow-y:hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    ul&::-webkit-scrollbar {
        display: none;
    }
    
    li {
        display: inline-block;
        vertical-align: top;
        width: 75px;
        padding-right: 20px;
        margin:20px 0 0 0;
    }
    

提交回复
热议问题