Text centered overlayed on video in Joomla module in HTML

狂风中的少年 提交于 2019-12-25 03:12:40

问题


Ok. Ive been struggling with this for a day. Can any one help?

I am trying to auto play a .mp4 video as the background in a Joomla CMS module with text overlaying on the top in the center of the module.

I decided simple html would be better than trying to find a plugin to do it.

Basically I want the video to auto play in the center (both horizontally and vertically) of the module. This is fairly easy as the video is the EXACT width of the module and height adjusts automatically. The module is responsive so no problems there. This code works:

<video width="1600" autoplay loop>
<source src="/newimages/capsulas-compatibles.mp4" type="video/mp4">
</video>

What I struggle with, is putting and H1 title over the top of the video in the center (both horizontally and vertically). So I tried the following html but the text simply appear before the video, not overlayed in the center of the video:

<div style="z-index:10; position:relative; top:0; text-align:center; vertical-align: middle; ">
<h1><font color="white">HERE IS MY TEXT</font></h1></div>
<div style="z-index:1;"><video width="1600" autoplay loop>
<source src="/newimages/myvideo.mp4" type="video/mp4">
</video></div>

Is it a problem with my code or that it is in a Joomla module? Any help greatly appreciated.


回答1:


Try following it will solve your issue:

<div style="z-index:10; position:relative; top:50%; left:50%; text-align:center; vertical-align: middle; position:absolute; ">
<h1><font color="white">HERE IS MY TEXT</font></h1></div>
<div style="z-index:1;"><video width="1600" autoplay loop>
<source src="/newimages/myvideo.mp4" type="video/mp4">
</video></div>

Make H1 DIV position:absolute; and give left:50%; and top:50%;.



来源:https://stackoverflow.com/questions/28739231/text-centered-overlayed-on-video-in-joomla-module-in-html

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