Archived topic
VIDEO ELEMENT HOOK
7 replies · Started by letsdoit on May 22, 2020
Hello Team,
I am trying to incorporate page hero element for http://cashmerestories.co/?page_id=8
I have -
created a hook element, added this in content section `<video loop muted autoplay poster="http://cashmerestories.co/wp-content/uploads/2020/05/JT-433.jpg" class="background-video">
<source src="http://cashmerestories.co/wp-content/uploads/2020/05/Yilin-Ashwin.mp4" type="video/mp4">
</video>
<div class="background-video-content">
Your Element content in here.
</div>`
Setting is before_header
Added this in css
.background-video {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.5;
}
.page-hero {
position: relative;
overflow: hidden;
}
.background-video-content {
position: relative;
z-index: 1;
}
video[poster] {
object-fit: cover;
width: 100%;
height: 100%;
}
But I am missing or doing something wrong as per the result on page.
Could you pls direct in right direction.
Regards
Hi there,
try using the Header Element instead of the Hook Element:
https://docs.generatepress.com/article/header-element-overview/
Hello David,
I tried doing Header Element at http://cashmerestories.co/?page_id=8 and hook element at http://cashmerestories.co/?page_id=3209
But none is working.
In the hero element give it some Top padding - best to use % padding to keep it responsive. Try 56% to match the video aspect ratio.
thanks David. It worked.
Just asking, I understand it is out of scope. But has anyone also added a play pause button on top of video via some way or mute unmute button!
Thanks for help anyways.
There is the default controls - which probably won't be fitting:
https://www.w3schools.com/tags/att_video_controls.asp
Anything more than that requires JS and custom development.
Found this article which gives some pointers:
https://blog.teamtreehouse.com/building-custom-controls-for-html5-videos
thanks David for this. This seems quite helpful.
You're welcome