How to make responsive video container div? - html

I'm trying to make video container div responsive but couldn't manage it so far.
My current CSS for video and container:
.header-container{
width: 100% !important;
height: auto !important;
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;
opacity: 0.78;
widows: 100%;
width: 100% !important;
height: auto !important;
margin:0 auto;
}
HTML:
<div class="header-container">
<div class="video-container">
<video preload ="true" autoplay loop = "loop" volume = "0" style="width: 100%;
height: auto;">
<source src = "webd.mp4" type = "video/mp4" >
</video>
</div>
</div>
Current look:
Current look
Could you please tell me how can I fix it? I'm still new in HTML and CSS and I really need your help & advice.

https://jsfiddle.net/mlegg10/fsftz8rt
/* Flexible iFrame */
.flexible-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.flexible-container iframe,
.flexible-container object,
.flexible-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<!-- Responsive iFrame -->
<div class="flexible-container">
<iframe src="<source src = "webd.mp4" type = "video/mp4" >" frameborder="0" style="border:0"></iframe>
</div>

a large deal of your code does not associate itself between html and css so it would be helpful to you to understand how it works. Firstly, video is not styled due to it being referenced as .video in your css and your video container has the opposite with the reference being video-container with no dot so your css should look like this
.header-container {
width: 100% !important;
height: auto !important;
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;
opacity: 0.78;
widows: 100%;
width: 100% !important;
height: auto !important;
margin: 0 auto;
}
To make a view response you need to scale with its parent and to have most things with % to do this you need to add
position: relative;
to all the parents
After this you need to remove the position absolute as it will mess up your styling by making it an object that does not scale properly
Here is an example of what I think you mean:
https://jsfiddle.net/afut7y99/
Change the sliders at the sides to see how it resizes.

Related

Iframe - Problems with centering

I have some problems with an iframe centering.
The code is setup to keep the same ratio, so it is 100% reposonsive.
This also causes VERY LIMITED possibilies for adding formattiong and - Centering
I have tired to both add a container box, and changing the css styling but I cant seam to get it to work...
any idears
<div class="background background_video">
<div id="video_container">
<div class="youtube-video-container">
<iframe class="youtube-video" src="https://www.youtube.com/embed/8aGhZQkoFbQ"></iframe>
</div>
</div>
</div>
.youtube-video-container {
padding-top: 56.25%;
height: 0px;
position: relative;
}
.youtube-video {
width: 60%;
height: 60%;
position: absolute;
top: 0;
left: 0;
border: 0;
}
.youtube-video-container {
height: 300px; // some height
position: relative;
}
.youtube-video {
width: 60%;
height: 60%;
position: absolute;
bottom: 0;
left: 0;
border: 0;
display: block;
}
as I correct understand question
FROM ANOTHER POST I FOUND...
Thanks for the trying to help anyways guys!
Without knowing the width/height of the positioned1 element, it is still possible to align it as follows:
EXAMPLE HERE
.child {
position: absolute;
top: 50%; /* position the top edge of the element at the middle of the parent */
left: 50%; /* position the left edge of the element at the middle of the parent */
transform: translate(-50%, -50%); /* This is a shorthand of
translateX(-50%) and translateY(-50%) */
}
It's worth noting that CSS Transform is supported in IE9 and above. (Vendor prefixes omitted
In this responsive 16:9 youtube css, all parents of #video_container have to be set to an height 100%.
Click on Run code, then 'Full page' to see the result.
html, body {
height: 100%;
margin: 0;
}
.background_video {
height: 100%;
display: flex;
}
#video_container {
width: 60%;
margin: auto;
}
.youtube-video-container {
position: relative;
display: block;
width: 100%;
padding: 0;
overflow: hidden;
}
.youtube-video-container::before {
display: block;
content: "";
padding-top: 56.25%;
}
.youtube-video-container iframe {
position: absolute;
top: 0; bottom: 0; left: 0;
width: 100%;
height: 100%;
border: 0;
}
<div class="background background_video">
<div id="video_container">
<div class="youtube-video-container">
<iframe class="youtube-video" src="https://www.youtube.com/embed/8aGhZQkoFbQ"></iframe>
</div>
</div>
</div>

Overlay div in bottom right corner of video in CSS

Is it possible to overlay something on a video element without having to set the container div height and width like is done in the example below?
.container {
position: relative;
width: 640px;
height: 360px;
}
.overlay {
position: absolute;
bottom: 0px;
right: 0px;
font-size: 18px;
padding: .2em .2em;
background-color: #fefefe;
}
video {
position: absolute;
}
<div class="container">
<video src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_5MB.mp4" width="640" height="360"></video>
<div class="overlay">Overlay</div>
</div>
One solution I found was to set the width and height of the video element to take 100% of the container div size.
I modified the code snippet so you can check the results below.
.container {
position: relative;
}
.overlay {
position: absolute;
bottom: 0px;
right: 0px;
font-size: 18px;
padding: .2em .2em;
background-color: #fefefe;
z-index: 999;
}
video {
width: 100%;
height: 100%;
}
<div class="container">
<video src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_5MB.mp4" width="640" height="360"></video>
<div class="overlay">Overlay</div>
</div>

Responsive iframe, how to remove overflow border

I'm trying to embed a video using an iframe but I'm getting some annoying overflow padding that I can't seem to get rid of.
The code at the top is a way of forcing an iframe into a responsive style so that you can view it on mobile.
Basically the 'padding-bottom' code is controlling the aspect ratio of the frame.
I got the code from here:
https://www.smashingmagazine.com/2014/02/making-embedded-content-work-in-responsive-design/
I've checked here: Making responsive iframe and this leaves me with horrible overflow too.
The result is below:
Image displaying overflow issue
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 0px;
padding-right: 0px;
height: 0;
overflow: hidden;
}
.video-container iframe {
position: absolute;
top: 0;
bottom: 0;
left: 0px;
right: 0px;
width: 100%;
height: 100%;
}
</style>
<div class="video-container">
<iframe scrolling="no" src="https://06-lvl3-pdl.vimeocdn.com/01/4345/3/96727205/257828362.mp4?expires=1497358367&token=0ef4c2c1316f5f76d532a" frameBorder="0"></iframe>
</div>
Changing the padding-bottom: to 56.35% just moves the black overflow line to the bottom of the video instead of the side.
height 100vh will take 100% of viewport and margin:0 and padding:0 remove default properties.
Just add
.video-container {
position: relative;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0px;
width: 100%; /* Add this */
height: 100vh; /* Add this */
padding:0px; /* Add this */
margin:0px; /* Add this */
}
.video-container {
position: relative;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0px;
width: 100%;
height: 100vh;
padding:0px;
margin:0px;
}
<div class="video-container">
<iframe scrolling="no" src="https://06-lvl3-pdl.vimeocdn.com/01/4345/3/96727205/257828362.mp4?expires=1497358367&token=0ef4c2c1316f5f76d532a" frameBorder="0"></iframe>
</div>
I just did this instead. It works - gets around the user agent style sheet that Chrome uses and applies correct styling.
<style type="text/css">
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 0px;
padding-right: 0px;
height: 0;
border: 0;
overflow: hidden;
}
</style>
<div class="video-container">
<video style="width:100%;" src="https://06-lvl3-pdl.vimeocdn.com/01/4345/3/96727205/257828362.mp4?expires=1497358367&token=0ef4c2c1316f5f76d532a" controls autoplay type="video/mp4"></video>
</div>
position: relative;
padding-bottom: 56.25%;
padding-top: 0px;
padding-right: 0px;
height: 0;
overflow: hidden;
}
.video-container iframe {
position: absolute;
top: 0;
bottom: 0;
left: 0px;
right: 0px;
width: 100%;
height: 100%;
}
</style>
<div class="video-container">
<iframe scrolling="no" src="https://06-lvl3-pdl.vimeocdn.com/01/4345/3/96727205/257828362.mp4?expires=1497358367&token=0ef4c2c1316f5f76d532a" frameBorder="0"></iframe>
</div>

Make box that fits video in aspect ratio, plus static sized footer

I want to have something that looks a bit like this:
Where the bear image in the middle is a video. The div which contains the video should be 16:9, and the footer should be some static height and 100% width.
Although I have found a handy little mixin for matching an aspect ratio, I am having trouble reconciling it with the statically sized bottom part.
To start with the video container, I essentially had the following:
<div class="container">
<div class="content">
<video src="http://www.w3schools.com/html/movie.mp4" autoplay />
</div>
</div>
With the following (S)CSS:
.container {
position: relative;
&::before {
display: block;
content: "";
width: 100%;
padding-top: 56.25%; // 16:9
}
& > .content {
top: 0;
left: 0;
right: 0;
bottom: 0;
position: absolute;
}
}
How could I add this statically sized bar to the bottom of the box that maintains aspect ratio?
For convenience of answering, here is a codepen with what I more or less have
The outer container usually has a height of 0, it's the padding that stretches around the video like saran wrap.
SNIPPET
html {
font: 400 16px/1.428 Consolas;
box-sizing: border-box
}
html,
body {
height: 100%;
width: 100%;
}
*,
*::after,
*::before {
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0 none transparent;
}
.vWrap {
border: 0 none transparent;
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.vid {
position: absolute;
width: 100%;
height: auto%;
max-height: 96%;
left: 0;
top: 0;
}
footer {
width: 100%;
height: 40px;
clear: both;
position: relative;
}
<div class='vWrap'>
<video id='vid1' class='vid' src='http://media6000.dropshots.com/photos/1381926/20170326/005611.mp4' controls>
</video>
</div>
<footer class='footer'></footer>

Video hides when logo div is removed

Hello fellow stackers.
I've got a slight problem. I'm trying to duplicated my webpage for another page, however whenever I try and remove the logo the video disappears. Not to sure why. I've input the code however I don't think its much use because it works find by itself, which leads me to believe that there is something within my code which relies on the logo being there. Your help is much obliged. The live example is here. If you inspect element on any browser and remove the logo you'll find that it disappears.
.Intro-Video {
position: relative;
z-index: 9999;
width: 100%;
display: block;
background-color: #fff;
overflow: hidden;
}
.Intro-Video1 {
position: relative;
z-index: 9999;
width: 100%;
display: block;
margin-top: 200px;
background-color: #fff;
overflow: hidden;
}
.video-box {
height: 100%;
width: 100%;
position: relative;
}
#video-container {
height:100%;
width:100%;
overflow: hidden;
}
video {
position:absolute;
z-index:0;
}
video.fillWidth {
width: 100%;
}
.Kadeem-Logo {
position: relative;
top: 0px;
width: 100%;
display:block;
}
.Kadeem-Logo img {
display: block;
width: auto;
max-width: 100%;
}
<div class="video-box">
<div id="video-container">
<video autoplay class="fillWidth">
<source src="http://client.hugoandmarie.com.s35719.gridserver.com/client/AlexandraPosen/Alex_Posen_Video.mp4" type="video/mp4" />
</video>
<div class="Kadeem-Logo">
<img src="http://www.kadeem.london/Content/Image/KL.png" alt="Kadeem Logo" title="Kadeem Logo">
</div>
</div>
</div>
</div>
Your logo image is providing all the height for the container.
Try this:
#video-container {
height: 550px; /* Or whatever height you want */
}
To fix the issue.