div横向滚动效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body{
            padding: 0;
            margin: 0;
        }
        .box{
            width: 100%;
            height: 300px;
            background-color: #00aaee;
        }
        .box .box-item{
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
 
            /* width:200px; */
            width: 100%;
            height: 50px;
 
            overflow-x: scroll;
            overflow-y: hidden; 
            /* overflow: auto; */
            white-space: nowrap;
            background-color: #ff0000;
        }
        .box .box-item .item-group{
            /* float: left; */
            flex: 0 0 100px;
            width: 100px;
            text-align: center;
            box-sizing: border-box;
            border-right: 1px solid #ccc;
        }
        ::-webkit-scrollbar {
            display: none
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box-item">
            <span></span>
                <div class="item-group">1</div>
                <div class="item-group">2</div>
                <div class="item-group">3</div>
                <div class="item-group">4</div>
                <div class="item-group">5</div>
                <div class="item-group">6</div>
                <div class="item-group">7</div>
                <div class="item-group">8</div>
                <div class="item-group">9</div>
                <div class="item-group">10</div>
                <div class="item-group">11</div>
                <div class="item-group">12</div>
        </div>
    </div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/L1147484597/article/details/121468059
今日推荐