Add text above HTML5 Video

回眸只為那壹抹淺笑 提交于 2019-12-18 03:04:41

问题


Need Help on adding text on top of, so the text is overlaying an HTML 5 Video, And I also need to add a form inputs and buttons as well below is my HTML5 Video Code.

<video id="video" width="770" height="882" onclick="play();">
<source src="video/Motion.mp4" type="video/mp4" />
</video>

回答1:


Surely you are looking for more than this:

<div class="container">
    <video id="video" width="770" height="882" onclick="play();">
        <source src="video/Motion.mp4" type="video/mp4" />
    </video>
    <div class="overlay">
        <p>Content above your video</p>
        <form>
            <p>Content Below Your Video</p>
            <label for="input">Form Input Label</label>
            <input id="input" name="input" value="" />
            <button type="submit">Submit</button>
        </form>
    </div>
</div>

If you want to put the content on top of the video, you would use some kind of positioning:

.container { position:relative; }
.container video {
    position:relative;
    z-index:0;
}
.overlay {
    position:absolute;
    top:0;
    left:0;
    z-index:1;
}



回答2:


You can use top and left position to be in percentage. as it will auto adjust top text when the window content size will change

<div class="container">
    <video id="video" width="770" height="882" onclick="play();">
        <source src="video/Motion.mp4" type="video/mp4" />
    </video>
    <div class="overlayText">
        <p id="topText">Content above your video</p>
    </div>
</div>`enter code here`

#overlayText {
 position:absolute;
  top:30%;
  left:20%;
  z-index:1;
}

#topText {
  color: white;
  font-size: 20px;
  align-self: center;
}


来源:https://stackoverflow.com/questions/10422105/add-text-above-html5-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!