how to make a video angled - html

I try to put a video into my website and. I want the video to be slanted.
I want that the video fill the white div. I don't know how to do that. Can someone please help me out?
.video {
position: absolute;
left: 50%;
transform: translate(-50%, 50%);
height: 400px;
width: 100%;
background-color: white;
box-shadow: 0 25px 30px rgba(0, 0, 0, .5);
display: flex;
}
.video1 {
height: 100%;
background: #222629;
width: 50%;
box-sizing: border-box;
}
#myVideo {
height: 400px;
width: 100%;
object-fit: cover;
}
.video2 {
width: 50%;
height: 100%;
box-sizing: border-box;
border-left: 100px solid #222629;
border-bottom: 400px solid transparent;
}
<div class="video">
<div class="video1"></div>
<div class="video2">
<video autoplay muted loop id="myVideo">
<source src="<img/background_video.mp4" type="video/mp4">
</video>
</div>
</div>

I've re-structured your html to make it easier to understand.
Main Idea & Explanation:
The main idea is to have 1 container div that holds all the divs. This will act as the parent div.
Then to have 3 child divs inside the parent div.
2 of the child divs will be for the left section. 1 will be for the right section.
One of the left child div will be for when it we use skew on it. The other left div is to cover up the gap. We also use overflow: hidden to hide the slanted part which is sticking out of the parent container.
The right div is pretty easy, its just to hold the video.
Try this:
.video-container {
width: 100%;
position: relative;
}
.left-video-slanted {
background-color: #222629;
width: 50%;
height: 400px;
position: absolute;
left: 120px;
transform: skew(-30deg);
z-index:99;
}
.left-video {
background-color: #222629;
width: 50%;
height: 400px;
position: absolute;
left: 0;
z-index: 99;
}
.right-video {
width: 50%;
height: 400px;
position: absolute;
right: 0;
overflow: hidden;
}
#myVideo {
position: absolute;
right: 0;
height: 400px;
}
<div class="video-container">
<div class="left-video-slanted"></div>
<div class="left-video"></div>
<div class="right-video">
<video autoplay muted loop id="myVideo">
<source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4">
</video>
</div>
</div>
Edit:
Added overflow: hidden to hide the extended video.

Here's sample you can skew video to tile within a particular fragment. You need to do adjustments to ensure appropriate tiling acrroding to skew angle.
Hope this help!
Excuse using simplified layout instead or your original css; also don't forget to checkout Browser Compatibility Table.
body {margin: 0;} /* Ignore */
.video {width: 100%; display: table;}
.video1, .video2 {width: 45%; display: table-cell; background: #333;}
.video1 {color: #eee; text-align: center;}
#myVideo {width: 92%; transform: skewX(-15deg);}
<h3>Sample SKEW -15</h3>
<div class="video">
<div class="video1">
Video 1 :)
</div>
<div class="video2">
<video autoplay muted loop id="myVideo">
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" type="video/mp4" />
</video>
</div>
</div>
NJoy!
-Adesh

Related

Video text overlay with "responsive" center alignment

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>

Responsive centering an image using css, bootstrap

I am trying to center an image that has a background video container. I would like for it to be exactly centered vertically and horizontally. At the moment i can only center the image horizontally but having trouble centering it vertically. When i do center the image it does'nt become responsive. Any ideas?
This is how it looks on my header area:
http://imgur.com/a/N6vNg
HTML code:
<div class="header-container">
<div class="video-container">
<video preload="true" autoplay="autoplay" loop="loop" volume= "0">
<source src="video/backgroundAnime.mp4" type="video/mp4">
<source src="video/backgroundAnime.webm" type="video/webm">
<source src="video/backgroundAnime.ogv" type="video/ogg">
</video>
</div>
<img src="img/albayda.png" class="img-responsive center-block">
</div>
CSS code:
.header-container{
width: 100%;
height: 800px;
border-left: none;
border-right: none;
position: relative;
padding: 20px;
}
.video-container{
position: absolute;
top: 0%;
left: 0%;
height: 100%;
width: 100%;
overflow: hidden;
}
video{
position: absolute;
z-index: -1;
width: 100%;
}
.img-responsive{
margin:0 auto;
}
.header-container img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
That should do it.
Instead of using <img> tag you may use a <div> with centered non-repeating background and then make it fill container with position:absolue;left:0;right:0;top:0;bottom:0 and optional pointer-events:none.

Background video taking full height of site instead of container

Hello I have a div with a <video> tag in it, and this is set as the background of the div. I have it working but when I go on to create a div below that, the video extends into that div. Basically the video extends beyond its parent container into other divs. It looks like it is taking the full height of the site instead of the full height of the div.
Here is my code:
.banner {
height: 903px;
width: 100%;
}
.banner video {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1;
background: url() no-repeat;
background-size: cover;
}
<div class="banner">
<video autoplay="" loop="">
<source src="//myvid.mp4" type="video/mp4">
<source src="//myvid.ogg" type="video/ogg">
</video>
</div>
Does anyone know why it is doing this?
Thanks!
change position:fixed to absolute and let the parent container be position:relative
check this snippet
.banner {
height: 200px;
width: 100%;
border: 1px solid green;
position: relative;
}
.banner video {
position: absolute;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
background: url() no-repeat;
background-size: cover;
}
<div class="banner">
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
</div>
<div>
whkjshfdksjhdfksdf
</div>
Hope it helps
You have position: fixed change that to absolute. Since fixed takes the current Display scope seperated from the parent elements. Thus scrolls and takes up everything since you used widht: 100%; height: 100%;
You might also add position: relative; to the banner class so the video has it as a parent.
In addition to changes to defaults, there are changes to position of .banner (relative) and the video (absolute), and the height of the video has been modified to a percentage that maintains a 16:9 aspect ratio. To demonstrate that it covers only it's container(.banner), .banner is set at half the lengths of viewport. Please review the Snippet in Full page mode.
SNIPPET
html,
body {
width: 100%;
height: 100%;
font: 400 16px/1.428 Verdana;
color: #eee;
overflow-x: hidden;
overflow-y: auto;
}
*,
*:before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0;
outline: none;
}
.banner {
position: relative;
height: 28vh;
width: 50vw;
}
.banner video {
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
min-width: 100%;
min-height: 56.25%;
width: auto;
height: auto;
z-index: 0;
/*background: url() no-repeat;*/
background-size: cover;
}
<div class="banner">
<video id="vid1" class="vid" src="http://html5demos.com/assets/dizzy.mp4" controls>
</video>
</div>

Centering Text in Responsive Video Background

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;
}

How to hide end of a video in a div box with overflow: hidden?

I want to hide the ends of a video >(greater in size) div-box like with an image using overflow: hidden (and without losing the proportion of the video). The codes I used:
CSS3
#cookVideo { /*Video Box*/
display: inline;
position: relative;
background-clip:border-box;
float: left;
z-index: 2;
min-width: 50%;
max-width: 50%;
min-height: 400px;
height: 400px;
width: 50%;
margin-top: -8px;
padding: 0px;
}
#dynamic {/* Container - Zoom Image and Cooking Video*/
position: relative;
top: 0px;
margin-left: -11px;
display: block;
float: left;
width: 100%;
height: 382px;
overflow: hidden;
/*border: 1px solid green;*/
}
HTML PART
<section id="midContainer">
<article>
<header id="dynamic">
<video id="cookVideo" autoplay loop>
<source src="css/images/Shrimpsmall.mp4">
</video>
</header>
</article>
</section>
It would be best to use a plugin if you want it to be responsive or to use percentages. Here is an example using Vide
The video is wrapped in another div and when the plugin is called, it stretches the video to cover the wrapper kind of like how background-size:cover works.
$('#cookVideo').vide();
#dynamic {
position: relative;
top: 0px;
margin-left: -11px;
display: block;
float: left;
width: 100%;
height: 382px;
overflow: hidden;
/* border: 1px solid green; */
}
#cookVideo-wrapper {
display: inline;
position: relative;
background-clip: border-box;
float: left;
z-index: 2;
height: 400px;
width: 50%;
margin-top: -8px;
padding: 0px;
overflow:hidden;
}
#zoomImage {
display: inline;
position: relative;
float: left;
background: url("http://s3-ap-northeast-1.amazonaws.com/foodncake/css/images/Choco.jpg") center center;
background-size: cover;
background-repeat: no-repeat;
background-origin: content-box;
height: 400px;
width: 50%;
margin-left: 0px;
margin-top: 0px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://vodkabears.github.io/vide/js/jquery.vide.min.js"></script>
<header id="dynamic">
<div id="zoomImage"> </div>
<div id="cookVideo-wrapper">
<video id="cookVideo" autoplay="" loop="">
<source src="http://s3-ap-northeast-1.amazonaws.com/foodncake/css/images/Shrimpsmall.mp4">
</video>
</div>
</header>
If you want to do it manually, here are the points:
jsFiddle Demo
(1) Header (#dynamic) is an outer container div, styled as position:relative. This is necessary because the inner DIVs cannot be styled position:absolute unless their parent div is styled either absolute or relative
(2) Both #cookvideo and #olay (overlay) are inside the header, and are styled position:absolute.
(3) The overlay DIV should have background-color:transparent and use a thick border for the frame, OR use a background-image (png with a transparent middle) as a more sophisticated frame.
(4) It might be tricky to correctly position the frame because the browser stylesheets (part of each browser, not standard across browsers) do some basic styling to a video element. You may have to over-ride that default styling.