I want to create a responsive background video, but don't know how to change the alignment.
As far as I can see, the alignment currently is bottom right, but I want to change it to center center. (like background-position: center center)
Is there any way to achieve this?
Fiddle: http://jsfiddle.net/66dLhjxh/
HTML:
<video autoplay loop poster="http://demosthenes.info/assets/images/polina.jpg" id="bgvid">
<source src="http://demosthenes.info/assets/videos/polina.webm" type="video/webm">
<source src="http://demosthenes.info/assets/videos/polina.mp4" type="video/mp4">
</video>
CSS:
video {
position: fixed;
display:block;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
background-color:#fff;
background:url(../img/schrijven.jpg) no-repeat;
background-size: cover;
background-position: center center;
}
try this code DEMO
<div id="info">
Responsive Youtube embed......
</div>
<div class="holder">
<div class="video-container">
</div>
</div>
<button onclick="nextVideo()">Next Video</button>
</div>
.video-container {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 30px; /* size of chrome */
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container #overlay,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#overlay {
background:#000;
opacity:0.5;
/*background:rgba(255,255,255,0.8); or just this*/
z-index:50;
color:#fff;
}
with this is perfect
video {
position: fixed;
display:block;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
background-color:#fff;
background:url(../img/schrijven.jpg) no-repeat;
top: 0px;
left: 0px;
background-size: cover;
background-position: 50% 50%;
/*background-position: 30% 50%;*/
}
See it in action.
Related
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 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;
}
I am trying to align the video to the center of the image.
.vbackground {
background-image: url('http://s1.postimg.org/hdo0xh2of/image.png');
background-repeat: no-repeat;
width: 600px;
height: 600px;
position: relative;
}
#match {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='vbackground'>
<video controls id='match' width='300' height='300'>
<source src='match.mp4' type="video/mp4" />
</video>
</div>
How could I make the video at the center of the image (from all sides)? It currently gets aligned at the bottom of the image.
Try removing the position: absolute rule from the match id selector and set the text-align property on the .vbackground class to center.
This should work -
.vbackground {
background-image: url('http://s1.postimg.org/hdo0xh2of/image.png');
background-repeat: no-repeat;
width: 600px;
height: 600px;
position: relative;
text-align: center;
}
#match {
/*position: absolute;*/
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
Just add margin-left:auto and margin-right: auto; to your #match CSS STYLE and it will align the video to the center of the image.
#match {
margin-left: auto;
margin-right: auto;
}
I have a button that is sitting ontop of both a full screen video and an opaque overlay.
<section id="contact" class="threemonth-section">
<div class="container">
<video id="video_background" preload="auto" autoplay="true" muted="true" loop="loop" volume="0" >
<source src="video2.webm" type="video/webm">
<source src="video2.m4v" type="video/mp4"> Video not supported
</video>
<div id="overlay2"></div>
<div id="welcomingText">
<h2 class="welcoming">Welcome</h2>
<h3 class="to">to</h3>
<h1 class="mySite">my site</h1>
</div>
<button type="button" class="button"></button>
</div>
</section>
and here is the CSS for each part of this.
.threemonth-section {
height: 105%;
width: 100%;
position:relative;
display:table;
padding-top: 200px;
z-index:-5;
text-align: center;
background: url(../img/3monthNew.png) no-repeat center center scroll;
background-size:cover;
}
#video_background { position: absolute; z-index:-4; bottom: 0px; right: 0px; min-width: 100%; min-height: 100%; width: auto; height: 105%; overflow: hidden; }
#overlay2{
background-color:#000;
height:100%;
width:100%;
opacity:0.5;
z-index:-2;
position: absolute;
bottom: 0px; right: 0px; min-width: 100%; min-height: 100%; width: auto; height: auto; overflow: hidden;
}
#welcomingText{
margin-top:50px;
height:100%;
width:100%;
z-index:200;
color:#fff;
padding-top:15%;
z-index:-1;
margin-bottom:auto;
position: absolute;
bottom: 0px; right: 0px; min-width: 100%; min-height: 100%; width: auto; height: auto; overflow: hidden;
}
.button{
background: transparent url('button.png') no-repeat top;
height: 50px;
width:50px;
background-size:100%;
position:absolute;
z-index:2;
background-repeat:no-repeat;
margin-left: 267px;
}
I can't figure out why my button is un-clickable. I know its got no actions but It's being overlayed by something but I can't figure out why. Both positioning in my HTML and the z-index lead me to believe it should be on top?
It's probably pretty obvious but I've been staring at this for hours. Any ideas?