程序员一代码搬运工
【Java学习心得和Java学习技术个人总结】

纯CSS实现多个便签在一行展示,拖动滚动

div

<h2>请注意需要在移动端预览,PC端拖拽无效果</h2>
<div class="box">
    <span style="flex: 1;">保障类型</span>
    <p class="item">
        <span>标签1</span>
        <span>标签2</span>
        <span>标签3</span>
        <span>标签4</span>
        <span>标签5</span>
        <span>标签6</span>
        <span>标签7</span>
        <span>标签8</span>
        <span>标签9</span>
        <span>标签10</span>
        <span>标签11</span>
        <span>标签12</span>
        <span>标签13</span>
        <span>标签14</span>
        <span>标签15</span>
        <span>标签16</span>
        <span>标签17</span>
        <span>标签18</span>
        <span>标签19</span>
        <span>标签20</span>
        <span>标签21</span>
        <span>标签22</span>
        <span>标签23</span>
        <span>标签24</span>
        <span>标签25</span>
        <span>标签26</span>
        <span>标签27</span>
        <span>标签28</span>
    </p>
</div>

css

 .box {
    width:600px;
    height:40px;
    overflow-y:hidden;
    overflow-x:auto;
    white-space:nowrap;
    margin:100px;
    background-color:aqua;
}
.box::-webkit-scrollbar {
    display:none;
}
.item {
    width:384px;
    height:216px;
    display:inline-block;
}

 

赞(0)
未经允许不得转载:程序员一代码搬运工 » 纯CSS实现多个便签在一行展示,拖动滚动
分享到: 更多 (0)