css 父元宽度有子元素撑开

//在工作中用到 做个记录

//html
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
</ul>

//css
ul{height: 90px;line-height: 90px;overflow-x: scroll; white-space: nowrap;overflow-y: hidden;}
//主要思路就是使用white-space解决自动换行,overflow-x实现x溢出,宽度自适应,overflow-y解决上写两像素抖动的问题
//隐藏滚动条
ul::-webkit-scrollbar {display:none}
li{display: inline-block;width: 50%;}

猜你喜欢

转载自blog.csdn.net/weixin_33768153/article/details/77969247
今日推荐