I have to set a Vimeo as background for a div which is containing CTA box.
I found some example and made it possible to have the video background fullscreen and responsive as I needed.
But I found that the CTA box inside and the button are not clickable because of the "z-index" used to get the video back in the div.
play with z-index
moving element back and forth
.vimeo-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display:flex;
pointer-events: none;
overflow: hidden;
}
.vimeo-wrapper iframe {
width: 100vw;
height: 56.25vw; /* Given a 16:9 aspect ratio, 9/16*100 = 56.25 */
min-height: 100vh;
min-width: 177.77vh; /* Given a 16:9 aspect ratio, 16/9*100 = 177.77 */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}.content{
display:flex;
align-items:center;
justify-content:center;
z-index:1;
flex-wrap:wrap;
}.content,h2{
width:100%;
text-align:center;
color:white;
}
.CTA-wrapper{
border:2px solid white;
width:30%;
padding-bottom:2%;
}
div button:hover {
color: yellow;
}
<div class="vimeo-wrapper">
<iframe src="https://player.vimeo.com/video/342964528? background=1&autoplay=1&loop=1&byline=0&title=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div class="content">
<div class="CTA-wrapper">
<h2>CTA Header</h2>
<button class="btn-success">Click Me</button>
</div>
</div>
</div>
expected: clickable inside elements, fullscreen and responsive background video
result: not the clickable inside element
.CTA-wrapper{
position: relative;
z-index: 9999;
}
I think it will work
css
.vimeo-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display:flex;
pointer-events: none;
overflow: hidden;
}
.content,h2{
width:100%;
text-align:center;
color:white;
}
.CTA-wrapper{
border:2px solid white;
padding-bottom:2%;
}
.vimeo-wrapper-box {
width: 100%;
}
div button:hover {
color: yellow;
}
.iframe_wrapper {
position: relative;
padding-bottom: 56.25%;
}
.vimeo-wrapper iframe {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0px;
width: 100%;
height: 100%;
}
.vimeo-wrapper .content {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
text-align: center;
}
HTML
<div class="vimeo-wrapper">
<div class="vimeo-wrapper-box">
<h1>dfghfh</h1>
<div class="iframe_wrapper">
<iframe src="https://player.vimeo.com/video/342964528?background=1&autoplay=1&loop=1&byline=0&title=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div class="content">
<div class="CTA-wrapper">
<h2>CTA Header</h2>
<button class="btn-success">Click Me</button>
</div>
</div>
</div>
</div>
</div>
Related
I am trying to display a full width video with an overlay text that sits centered on the video vertically and horizontally. The centered positioning should respond to changes in the viewport width such that it is always centered. Also I would like a "caption" (h2 tag in the example) to always display right below the video regardless to how the viewport is sized.
I have attached my sample code - any help appreciated.
Thanks
Dennis
<head>
<style>
.header-unit {
margin-top: 10px;
}
#video-container {
height:100%;
width:100%;
overflow: hidden;
position: relative;
}
#video-overlay {
position: absolute;
z-index: 1;
font-size: 50px;
color: red;
margin: 0;
transform: translate(-50%, -50%);
width: 85%;
text-align: center;
top: 25%;
left: 50%;
}
video {
position: absolute;
z-index: 0;
}
video.fillWidth {
width: 100%;
}
</style>
</head>
<div class="header-unit">
<div id="video-container">
<p id="video-overlay">Get A Quote!</a></p>
<video autoplay muted loop class="fillWidth">
<source src="https://www.w3schools.com/html/mov_bbb.mp4"/>
</video>
</div>
</div>
<h2>Test Caption</h2>
Please update your css with this and check:
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.header-unit {
margin-top: 10px;
height: 100%;
}
#video-container {
height:100%;
width:100%;
overflow: hidden;
position: relative;
}
#video-overlay {
position: absolute;
z-index: 1;
font-size: 50px;
color: red;
margin: 0;
transform: translate(-50%, -50%);
width: 85%;
text-align: center;
top: 50%;
left: 50%;
}
video {
position: absolute;
z-index: 0;
}
video.fillWidth {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class="header-unit">
<div id="video-container">
<p id="video-overlay">Get A Quote!</a></p>
<video autoplay muted loop class="fillWidth">
<source src="https://www.w3schools.com/html/mov_bbb.mp4"/>
</video>
</div>
</div>
<h2>Test Caption</h2>
I am trying to make a background video with the fixed height of 700px without affecting the aspect ratio. video can crop. My issue is that the full height of the video is showing even I have provided a height of 700 px. Here is the code:
<div class="video-container">
<div class="video-overlay-text">
<h1>Some heading</h1>
<p>Sentence</p>
</div>
<video autoplay loop muted id="video-bg">
<source src="homepage-video-mp4_1.mp4" type="video/mp4" />
</video>
</div>
here is the CSS:
#video-bg {
position: relative;
width: auto;
min-width: 100%;
height: auto;
background: transparent url(video-bg.jpg) no-repeat;
background-size: cover;
}
video {
display: block;
position: absolute;
}
.video-container {
width: 100%;
height: 600px;
overflow: hidden;
position: relative;
top: 0;
right: 0;
z-index: 0;
}
.video-overlay-text {
position: absolute;
z-index: 5;
overflow: auto;
bottom: 20%;
left: 4%;
max-width: 700px;
margin: auto;
display: block;
}
.video-overlay-text h1 {
color: #ffffff;
font-size:34px;
line-height: 36px;
}
.video-overlay-text p {
color: #ffffff;
}
I have tried everything. Sometimes the mobile view gets cut and the text moves way up.
I have added max-height which will be helpful for all screen sizes. Also added a demo text to show the limit of the video. Hope this helps.
#video-bg {
position: relative;
width: auto;
min-width: 100%;
background: transparent url(video-bg.jpg) no-repeat;
background-size: cover;
}
video {
display: block;
position: absolute;
}
.video-container {
width: 100%;
max-height: 600px;
overflow: hidden;
position: relative;
top: 0;
right: 0;
z-index: 0;
}
.video-overlay-text {
position: absolute;
z-index: 5;
overflow: auto;
bottom: 20%;
left: 4%;
max-width: 700px;
margin: auto;
display: block;
}
.video-overlay-text h1 {
color: #ffffff;
font-size: 34px;
line-height: 36px;
}
.video-overlay-text p {
color: #ffffff;
}
<div class="video-container">
<div class="video-overlay-text">
<h1>Some heading</h1>
<p>Sentence</p>
</div>
<video autoplay loop muted id="video-bg">
<source src="//ak3.picdn.net/shutterstock/videos/2743133/preview/stock-footage-shanghai-china-circa-july-timelapse-video-of-shanghai-china-skyline-at-sunset-circa-july.mp4" type="video/mp4" />
</video>
</div>
<h2>Hello</h2>
I need to have some text centered within this video. I got rid of the container for the header, and the desired results are still in tact, so that works with me, but I've struggled to deal with centering this text!
<div class="video-container">
<video class="video" preload="true" autoplay = "autoplay" loop = "loop">
<source src="nyc.mp4" type="video/mp4"/>
</video>
<p class="center-block quote"> Test </p>
Styling:
.video-container {
position:absolute;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;
}
video {
margin-top:50px; /* gap b/w navbar and header */
position:absolute;
z-index: -1;
opacity: 0.78;
width: 100%;
margin: none;
padding: none;
}
Bootstrap has a built in helper class - .text-center
Try this: <div class="video-container text-center">
here a print screen
worked print screen
<!DOCTYPE html>
<html>
<body>
<style>
.center-block{text-align: center;}
.video-container {
position:absolute;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;
}
video {
margin-top:50px; /* gap b/w navbar and header */
position:absolute;
z-index: -1;
opacity: 0.78;
width: 100%;
margin: none;
padding: none;
}
</style>
<div class="video-container">
<video class="video" preload="true" autoplay = "autoplay" loop = "loop">
<source src="nyc.mp4" type="video/mp4"/>
</video>
<p class="center-block quote"> Test </p>
</div>
</body>
</html>
Use this
<p class="center-block quote" style="text-align:center;"> Test </p>
And also paste this one:
.video-container {
position:relative;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;
}
.video-container video{
position: fixed;
top: 100%;
left: 100%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
transform: translate(-100%, -100%);
}
.video-container{
justify-content: centre;
width: 100%;
height: 100%;
text-align: centre;
}
Is there a solution/tutorial for full width videos without borders?
I took a look at an existing solution:
Full-width vimeo wrapper background
I tried it but I'm getting unwanted (black) borders when I scale to different viewport sizes.
<div class="video">
<iframe src="https://player.vimeo.com/video/120893740?title=0& amp;byline=0&portrait=0&color=3a6774&autoplay=1&loop=1" width="960" height="600" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div
class="overlay">
<h1>HEADING HERE</h1>
<p>Content Here</p>
</div>
</div>
CSS:
body {
margin: 0;
padding: 0;
}
h1, p {
text-align: center
}
.video {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%}
.video iframe {
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
}
.video .overlay {
position: absolute;
z-index: 2;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0);
}
Thanks in advance
I've got a div with some text hidden by default. When you click on button, it will apear, but in IE11 (which I got), some part of div is covered under youtube iframe and I don't know, how to repair it :(
Here is the image of the problem:
HTML
<div class="product-spec-wrapper" style="z-index:999;">
<div class="product-spec-button">
<p>Specifikace produktu</p>
</div>
<div class="product-spec-holder" style="position:absolute; z-index:1001;">
<div class="additional-information-inner">
<div class="onajwrap">
<div class="product-spec-content">
//some content here
</div>
</div>
</div>
</div>
</div>
<div class="entry-content">
<div class="clicker"></div>
<div class='product-youtube'>
<h2>Video</h2>
<iframe width="560" height="315" src="https://www.youtube.com/embed/xF9yc5QtNzc?feature=oembed" frameborder="0" allowfullscreen></iframe>
</div>
</div>
CSS
.product-page .product-spec-wrapper {
width: 314px;
height: 50px;
position: relative;
z-index: 999;
padding-bottom: 18px;
border-bottom: 1px solid #d9d9d9;
padding-top: 20px;
}
.product-page .product-spec-wrapper .product-spec-holder {
position: absolute;
padding: 20px;
right: 0px;
top: 69px;
display: none;
}
.product-page .product-spec-wrapper .product-spec-holder .additional-information-inner {
position: relative;
background: none #f5fee7;
}
.product-spec-wrapper .additional-information-inner .onajwrap {
width: 920px;
height: 350px;
overflow-y: auto;
padding-left: 2px;
padding-right: 18px;
}
.clicker {
display: none;
position: fixed;
z-index: 998;
width: 5000em;
height: 5000em;
background-image: url("images/transparentspot.png");
left: 0px;
top: 0px;
}
.clicker.active {
display: block;
}
.product-page .entry-content {
float: left;
width: 613px;
}
.product-youtube {
width: 613px;
margin: 20px 0 20px 0;
}
.product-youtube iframe {
position:relative;
}
try this
.product-youtube iframe {
position:relative;
z-index: 1;
}
I solved my problem with adding wmode=opaque; to an iframe.