index.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!DOCTYPE html>
  2. <html lang="ch-zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>常中e大观园</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. width: 100vw;
  15. height: 100vh;
  16. max-width: 500px;
  17. margin: 0 auto;
  18. overflow: hidden;
  19. position: relative;
  20. }
  21. .videoBox {
  22. width: 100%;
  23. height: 100%;
  24. background-color: black;
  25. position: relative;
  26. }
  27. .videoBox video {
  28. position: absolute;
  29. top: 50%;
  30. left: 50%;
  31. transform: translate(-50%, -50%);
  32. max-width: 100%;
  33. max-height: 100%;
  34. }
  35. .skipTxt {
  36. position: absolute;
  37. z-index: 10;
  38. right: 15px;
  39. top: 15px;
  40. width: 60px;
  41. height: 30px;
  42. background-color: rgba(0, 0, 0, .6);
  43. line-height: 30px;
  44. text-align: center;
  45. color: #fff;
  46. text-decoration: none;
  47. }
  48. .videoImg {
  49. position: absolute;
  50. top: 0;
  51. left: 0;
  52. width: 100%;
  53. height: 100%;
  54. z-index: 100;
  55. }
  56. .videoImg img {
  57. width: 100%;
  58. height: 100%;
  59. }
  60. .videoImgBtn {
  61. position: absolute;
  62. left: 16%;
  63. bottom: 17%;
  64. width: 70%;
  65. height: 10%;
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <!-- 开场封面 -->
  71. <div class="videoImg">
  72. <img src="./myCode/cover.jpg" alt="">
  73. <div class="videoImgBtn"></div>
  74. </div>
  75. <!-- 开场视频 -->
  76. <div class="videoBox">
  77. <video src="./myCode/video.mp4" controls></video>
  78. <a class="skipTxt" href="./model.html">跳 过</a>
  79. </div>
  80. </body>
  81. <script>
  82. const videoBox = document.querySelector('.videoBox')
  83. const videoDom = document.querySelector('.videoBox video')
  84. const videoBtnDom = document.querySelector('.skipTxt')
  85. // 点击图片播放视频
  86. const videoImgBtn = document.querySelector('.videoImgBtn')
  87. videoImgBtn.onclick = () => {
  88. const videoImgDom = document.querySelector('.videoImg')
  89. videoImgDom.style.display = 'none'
  90. videoDom.play()
  91. }
  92. // videoDom.play()
  93. // 点击按钮,或者视频播放完毕的回调
  94. const videoPalyEnd = () => {
  95. videoBtnDom.click()
  96. // const topUrl = window.location.href
  97. // console.log('-------视频播放完毕,或者点击跳过--------', topUrl);
  98. // const a = document.createElement('a');
  99. // a.setAttribute('href', topUrl.replace('index', 'model'));
  100. // // a.setAttribute('target','_blank');
  101. // a.style.display = 'none'
  102. // document.body.appendChild(a);
  103. // a.click();
  104. }
  105. videoDom.addEventListener('ended', function () {
  106. videoPalyEnd()
  107. }, false)
  108. </script>
  109. </html>