123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <!DOCTYPE html>
- <html lang="ch-zh">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>常中e大观园</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- width: 100vw;
- height: 100vh;
- max-width: 500px;
- margin: 0 auto;
- overflow: hidden;
- position: relative;
- }
- .videoBox {
- width: 100%;
- height: 100%;
- background-color: black;
- position: relative;
- }
- .videoBox video {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- max-width: 100%;
- max-height: 100%;
- }
- .skipTxt {
- position: absolute;
- z-index: 10;
- right: 15px;
- top: 15px;
- width: 60px;
- height: 30px;
- background-color: rgba(0, 0, 0, .6);
- line-height: 30px;
- text-align: center;
- color: #fff;
- text-decoration: none;
- }
- .videoImg {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 100;
- }
- .videoImg img {
- width: 100%;
- height: 100%;
- }
- .videoImgBtn {
- position: absolute;
- left: 16%;
- bottom: 17%;
- width: 70%;
- height: 10%;
- }
- </style>
- </head>
- <body>
- <!-- 开场封面 -->
- <div class="videoImg">
- <img src="./myCode/cover.jpg" alt="">
- <div class="videoImgBtn"></div>
- </div>
- <!-- 开场视频 -->
- <div class="videoBox">
- <video src="./myCode/video.mp4" controls></video>
- <a class="skipTxt" href="./model.html">跳 过</a>
- </div>
- </body>
- <script>
- const videoBox = document.querySelector('.videoBox')
- const videoDom = document.querySelector('.videoBox video')
- const videoBtnDom = document.querySelector('.skipTxt')
- // 点击图片播放视频
- const videoImgBtn = document.querySelector('.videoImgBtn')
- videoImgBtn.onclick = () => {
- const videoImgDom = document.querySelector('.videoImg')
- videoImgDom.style.display = 'none'
- videoDom.play()
- }
- // videoDom.play()
- // 点击按钮,或者视频播放完毕的回调
- const videoPalyEnd = () => {
- videoBtnDom.click()
- // const topUrl = window.location.href
- // console.log('-------视频播放完毕,或者点击跳过--------', topUrl);
- // const a = document.createElement('a');
- // a.setAttribute('href', topUrl.replace('index', 'model'));
- // // a.setAttribute('target','_blank');
- // a.style.display = 'none'
- // document.body.appendChild(a);
- // a.click();
- }
- videoDom.addEventListener('ended', function () {
- videoPalyEnd()
- }, false)
- </script>
- </html>
|