直播app開發,載入時採用序幕從左向右拉開的效果

zhibo系統開發發表於2022-03-15

直播app開發,載入時採用序幕從左向右拉開的效果

<!DOCTYPE html>
<html>
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原生JS實現拖動拉開序幕特效</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
 
        body {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background: #151515;
        }
 
        div {
            position: relative;
        }
 
        #rangeValue {
            position: relative;
            display: block;
            font-size: 6em;
            color: rgba(0, 0, 0, 0.8);
            z-index: 2;
            text-align: center;
        }
 
        #rangeValue::after {
            content: '%';
        }
 
        #fillRangeValue {
            position: fixed;
            top: 0;
            left: 0;
            height: 100%;
            width: 0;
            background: #00adff;
            z-index: 1;
        }
 
        .range {
            position: relative;
            width: 400px;
            height: 15px;
            -webkit-appearance: none;
            background: rgba(0, 0, 0, 0.8);
            outline: none;
            border-radius: 15px;
            box-shadow: 0 0 0 2px #151515, inset 0 0 5px #000;
            z-index: 2;
            overflow: hidden;
        }
 
        .range::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 15px;
            height: 15px;
            border-radius: 50%;
            background: #00adff;
            border: 4px solid #222;
            z-index: 2;
            box-shadow: -407px 0 0 400px #00adff;
        }
    </style>
</head>
 
<body>
    <div>
        <h2 id="rangeValue"></h2>
        <div id="fillRangeValue"></div>
        <input type="range" value="0" min="0" max="100" onmousemove="rangeSlider(this.value)"
            onchange="rangeSlider(this.value)">
    </div>
    <script>
        function rangeSlider(value) {
            document.getElementById('rangeValue').innerHTML = value
            document.getElementById('fillRangeValue').style.width = `${value}%`
        }
    </script>
</body>
 
</html>

以上就是直播app開發,載入時採用序幕從左向右拉開的效果, 更多內容歡迎關注之後的文章


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

相關文章