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>
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 want to make some like this
Unfortunately the video does't show in full height, instead the video is bit out of the screen in height, i cannot even see controls.
I want the video to cover 100% height and width.
My css for this whole component is like this:
.screensaver {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: gray;
z-index: 9000;
.logo{
background-image: url(~#/assets/test.svg);
}
&-header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-image: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.00) 100%);
z-index: 1500;
display: flex;
align-items: center;
padding: $layout-size*1.25 $layout-size;
&-left{
flex: 0 0 320px;
}
}
&-body {
top: 0;
position: absolute;
height: 100vh;
width: 100vw;
&:after{
content:'';
background-color: rgba(0,0,0, 0.5);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
video{
min-height: 100%;
min-width: 100%;
height: 100vh;
display: block;
}
&-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 10;
}
}
}
=================
My vue Template:
<template>
<div class="screensaver">
<div class="screensaver-header">
<div class="screensaver-header-left">
<span class="logo">Test</span>
</div>
</div>
<div class="screensaver-body">
<video controls autoplay muted loop>
<source :src="require('test.mp4')" type="video/mp4">
</video>
<div class="screensaver-body-center">
<span>icon</span>
<h2>plz touch to unlock</h2>
</div>
</div>
</div>
Found a solution to this Problem. We can manipulate the Video Object, which can change the video optical but the changes are not big, we can easily use this.
video {
height: 100vh;
width: 100vw;
object-fit: fill;
}
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;
}
I am trying to make a video background as airbnb website, but I really can not figure it out how to make it works.
I am not sure is they use jquery or if I am missing something. In firefox looks pretty good but when I open the html in chrome, Internet explorer, Edge and safari the video is not visible.
This is the html and css, I really hope someone can help me.
I want the video will be with the same height, I dont want it to make it responsive, just like in the airbnb, but dont know how! More than a week I am trying to make it work and nothing :(
I want to make something similar to airbnb but not the same, thats why I copy and paste the html and css code.
Any help will be appreciated!
Thanks!
HTML
<div class="hero shift-with-hiw js-hero">
<div class="hero__background">
<video autoplay="autoplay" preload="auto" loop="loop" poster="http://dummyimage.com/320x240/ffffff/fff" class="video-playing" id="home-video">
<source src="https://a0.muscache.com/airbnb/static/P1-background-vid-compressed-2.mp4" type="video/mp4"></source>
<source src="https://a0.muscache.com/airbnb/static/P1-background-vid-compressed-2.webm" type="video/webm"></source> </video>
</div>
<div class="hero__content page-container page-container-full text-center">
<div class="va-container va-container-v va-container-h">
<div class="va-middle">
<div class="raise-30">
<h2 class="text-branding text-jumbo text-contrast hero__heading">Live There</h2>
</div>
</div>
</div>
</div>
</div>
CSS
.hero {
height: 400px;
position: relative;
}
.hero {
height: 600px;
}
.hero__background {
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
right: 0;
top: 0;
}
audio, canvas, video {
display: inline-block;
}
.hero__background video {
height: 100%;
position: absolute;
top: 0;
width: auto;
}
.hero__background video {
height: auto;
width: 100%;
}
.page-container-full::after {
clear: both;
}
.page-container-full::after {
clear: both;
}
.text-center {
text-align: center;
}
.page-container, .page-container-responsive {
margin-left: auto;
margin-right: auto;
padding-left: 24px;
padding-right: 24px;
}
.page-container-full {
width: auto;
}
.hero__content {
height: 400px;
position: relative;
z-index: 2;
}
.hero__content {
height: 550px;
padding-bottom: 104px;
top: 50px;
}
.va-container-h {
width: 100%;
}
.va-container-v {
height: 100%;
}
.va-container {
display: table;
position: relative;
}
.va-middle {
vertical-align: middle;
}
.va-top, .va-middle, .va-bottom {
display: table-cell;
}
.text-contrast {
color: #fff;
}
.text-branding {
text-transform: uppercase;
}
.text-jumbo {
font-size: 60px;
font-weight: 700;
}
Please update your CSS as follows:
.hero {
width: 100%;
height: 600px;
position: relative;
}
.hero__background {
width: 100%;
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
right: 0;
top: 0;
}
.hero__background video {
position: relative;
width: auto;
min-width: 100%;
height: auto;
}
I am attempting to display text on top of a video background. I have used simple HTML5 and CSS to do this. My code works great for desktop sites using Chrome, Safari and Firefox, but when a user views the page on an Android or iPhone device... only the text shows up and the video refuses to play (I am testing on an iPhone 6s Plus and a Samsung S5).
Here is a live preview of the page in question: http://buzzanimatedvideos.com/video-test/
And here is the CSS & HTML I am using:
.header-unit {
background: #fff;
border: 0 solid #fff;
height: 500px;
border: none;
position: relative;
padding: 0;
overflow: hidden;
text-align: center;
margin: 0 auto;
}
.video_container {
text-align: center;
margin: 0 auto;
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
video {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
min-height: 50%;
min-width: 50%;
}
.video-overlay {
position: relative;
z-index: 999;
text-align: center;
margin: 0 auto;
}
.video-overlay-color {
background-color: rgba(0,0,0,0.5);
position: absolute;
width: 100%;
height: 100%;
top: 0%;
bottom: 0;
left: auto;
right: auto;
margin: 0 auto;
text-align: center;
}
.video-overlay-content {
position: absolute;
z-index: 9999;
opacity: 1;
width: 100%;
height: 100%;
top: 25%;
bottom: 0;
left: auto;
right: auto;
margin: 0 auto;
text-align: center;
}
.video-overlay-content h1 {
max-width: 640px;
color: #fff;
margin: 0 auto;
text-align: center;
font-size: 3.1rem;
}
.video-overlay-content p {
margin-top: 1rem;
}
<div class="video-overlay">
<div class="header-unit">
<div class="video_container">
<video poster="/wp-content/themes/buzz/vid/video-still.jpg" preload autoplay loop>
<source src="http://buzzanimatedvideos.com/wp-content/uploads/2015/12/BuzzAnimated_HeroBG.mp4" type="video/mp4" />
<source src="http://buzzanimatedvideos.com/wp-content/uploads/2015/12/BuzzAnimated_HeroBG.webm" type="video/webm" />
<source src="http://buzzanimatedvideos.com/wp-content/uploads/2015/12/BuzzAnimated_HeroBG.ogv" type="video/ogg" />
</video>
</div>
</div>
<div class="video-overlay-color">
<div class="video-overlay-content">
<h1>ANIMATED VIDEOS THAT ENTERTAIN, EXPLAIN & GAIN NEW CUSTOMERS</h1>
<p>WATCH OUR VIDEOS</p>
</div>
</div>
</div>
Does anyone know what the issue is? I have been searching high and low for some type of clue but I have nothing. =/ Thanks for your help!
Awesome. I did not know that. That said, I solved the autoplay on mobile by converting the video into a GIF. I hide the video below 640px and display the GIF instead. The GIF just keeps looping regardless of user input, so it works quite well.