首页 > 解决方案 > 使 html5 视频 div 可点击并转到超链接

问题描述

我目前有一个视频链接

<video onclick="location.href='/video';" width="320" height="240" controls loop autoplay>
<source src="/static/backgroundremover.mp4" type="video/mp4">
<source src="/static/backgroundremover.ogg" type="video/ogg">
<img src="/static/backgroundremover.gif">
Your browser does not support the video tag.
</video>

但是上面的 div 我把它包裹在一个<a href>但每次我点击任何视频时它只是暂停视频而不是转到超链接。

当有人点击视频让它转到另一个网址时,我该怎么做,即/video

标签: htmlhtml5-video

解决方案


在评论的一些帮助之后,我问了这个问题,在回答这个问题时我回答了这个问题,所以我会继续在这里发布它,但是工作的 css 和 html。

#video {     position: relative; left: 0px; top: 0px; min-height: 100%;
         min-width: 100%; z-index: 9997; }
#overlay { position: absolute; left: 0px; top: 0px; height: 100%; width: 100%;
           z-index: 9998; }
#main_container {position: relative; left:0; top:0; }

和 html

<div id="main_container"class="d-none d-md-block">
  <div id="overlay"></div>
  <video id="video" width="320" height="240" controls loop autoplay>
  <source src="/static/backgroundremover.mp4" type="video/mp4">
  <source src="/static/backgroundremover.ogg" type="video/ogg">
  <img src="/static/backgroundremover.gif">
  Your browser does not support the video tag.
  </video>
</div>

推荐阅读