<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小说翻页功能</title>
    <script src="../../common/jquery-3.4.1.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
 
        :root,
        html,
        body {
            width: 100%;
            height: 100%;
            position: relative;
        }
 
        body::after {
            content: "";
            clear: both;
        }
 
        .wrapper {
            width: 400px;
            height: 600px;
            border: 1px solid #ddd;
            border-radius: 4px;
            overflow: hidden;
            padding: 10px;
            position: absolute;
            left: calc(50% - 200px);
            top: 50px;
        }
 
        .wrapper .content {
            width: 100%;
            height: 100%;
            column-width: 400px;
            column-gap: 30px;
        }
 
        .wrapper .content p {
            text-align: center;
            font-size: 22px;
            font-weight: 500;
            padding: 10px;
        }
 
        .footer {
            width: 400px;
            height: 40px;
            line-height: 40px;
            position: absolute;
            top: 675px;
            left: calc(50% - 200px);
        }
    </style>
</head>
  
<body>
    <div class="wrapper">
        <div class="content">
            <p> 好看的小说</p>


 

             

</div>
    </div>
    <div class="footer">当前是第1页,鼠标点击左右滑动切换页数</div>
 
    <script>
        (function () {
            var $content = $('.content'), startPositionX = null, endPostionX = null, index = 0, $footer = $('.footer');
            $content.on('mousedown', function (e) {
                startPositionX = e.clientX;
                $content.on('mousemove', function (event) {
                    endPostionX = event.clientX;
                })
            })
            $content.on('mouseup', function () {
                if (startPositionX - endPostionX > 0) {
                    if (index == 17) {
                        alert('已经在最后一页了哦!');
                        return;
                    }
                    index++;
                    $content.css('transform', 'translateX(-' + (430 * index) + 'px)')
                    console.log('鼠标左滑')
                } else {
                    // 右滑
                    if (index == 0) {
                        alert('已经在第一页了哦!');
                        return;
                    }
                    index -= 1
                    $content.css('transform', 'translateX( -' + (430 * index) + 'px)')
                    console.log('鼠标右滑')
                }
                $footer.text('当前是第' + (index + 1) + '页,鼠标点击左右滑动切换页数')
            })
        })()
 
    </script>
</body>
</html>

 

android小说翻页实现 小说按键翻页_android小说翻页实现

 

android小说翻页实现 小说按键翻页_大数据_02