美文网首页
div横向排列+滚动条显示

div横向排列+滚动条显示

作者: webjiacheng | 来源:发表于2018-03-19 18:11 被阅读0次

实现多个div在容器内横向排列,
利用white-space这个属性防止父容器内容换行,
同时将容器内元素设置为行内块 display:inline-block来实现。
例子中每个子元素宽度限定为三分之一以上

.container{
    width: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
}
.container .item{
    display:inline-block;
    box-sizing: border-box;
    width:33%;
}

相关文章

网友评论

      本文标题:div横向排列+滚动条显示

      本文链接:https://www.haomeiwen.com/subject/mywpqftx.html