成品直播原始碼,點選滑動切換效果

zhibo系統開發發表於2022-02-23

成品直播原始碼,點選滑動切換效果實現的相關程式碼

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .nav {
            list-style: none;
            display: flex;
           
            height: 40px;
        }
        .nav li{
            width: 33.3%;
        }
        .mainbody{
            display: flex;
            transition: all 0.6s linear;
            width: 5760px;
        }
        .mainbody div{
           
            width: 1920px;
            height: 500px;
        }
    </style>
</head>
<body>
    <div>
        <ul>
                <li id="yesterday">昨天</li>
                <li id="today">今天</li>
                <li onclick="tomorrow">明天</li>
        </ul>
        <div>
            <div style="background-color: red;"></div>
            <div style="background-color:yellow;"></div>
            <div style="background-color:black;"></div>
                
        </div>
    </div>
    <script>
        let mainbody = document.querySelector('.mainbody')
        let yesterday = document.getElementById("yesterday")
        let today = document.getElementById("today")
        yesterday.addEventListener("click",()=>{
            mainbody.style.transform = "translateX(0px)"
        })
        today.addEventListener('click',()=>{
            mainbody.style.transform = "translateX(-1920px)"
        })
    </script>
</body>
</html>

以上就是 成品直播原始碼,點選滑動切換效果實現的相關程式碼,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2857432/,如需轉載,請註明出處,否則將追究法律責任。

相關文章