html crops height video to height 100vh, video to fullscreen - html

I am struggling with a stupid little thing. Working on this site:
(sorry for the slow server, school stuff you know)
The video you'll see is on height vh100, which is what i want. When I have this video on the max height of your browser the width of the video is not fullscreen.
The code I have now:
HTML
<!-- video -->
<video id="moodvideo" autoplay loop>
<source src="moodvideo.mp4" type='video/mp4'>
</video>
CSS
/* Video */
video {
height: 100vh;
width: 100vw;
}
What I am trying to achieve is the video on full screen, width 100wh and height 100vh. If the height (of the video with width 100wh) is bigger then the height 100vh, I want the video to crop so it will be on fullscreen view on the max width and height your browser. By cropping, I don't bother to missing some of the video (50px from the bottom or so), fullscreen in width and height is more important to me.
Now, I already searched and tried a lot before asking you guys, things like; vw100/vh100, min-height/width 100, add the movie in a div, div to 100 vh/vw, and some scripts I found but nothing really works...

You could use the jquery videoBG plugin: http://syddev.com/jquery.videoBG/
Or you could add the following code: https://jsfiddle.net/wcv2ak9p/1/
The alternative image is displayed when the browser doesn't support the video.
HTML
<video id="moodvideo" autoplay loop>
<source src="moodvideo.mp4" type='video/mp4'>
<img id="alternative" src="alternative.jpg" />
</video>
CSS
#moodvideo, #alternative {
width: 100vw; /* Could also use width: 100%; */
height: 100vh;
object-fit: cover;
position: fixed; /* Change position to absolute if you don't want it to take up the whole page */
left: 0px;
top: 0px;
z-index: -1;
}

Related

How to style a video to take fit an entire div, keep aspect ratio and be responsive as the page shrinks?

Im trying to do this exact thing https://www.javycoffee.com/
Found a solution that gets me closest to my result. I put the video on its own page. Made it the page background image and then scaled it.
Keep it on its own page, dont use container and use max-height to scale it.
CSS
const StyledVideo = styled.video`
filter: saturate(1.1) contrast(0.7) opacity(0.79) brightness(0.9);
object-fit: cover;
width: 100% !important;
max-height: 600px !important;
`;
function Video() {
return (
<StyledVideo autoPlay muted loop id="myVideo">
<source src={} type="video/mp4" />
</StyledVideo>
);
}
export default Video;

how to make a responsive vertical video on html css?

I've to insert a vertical video on my website built using html css. the video must be in left side and it should be responsive. This code is displaying the vertical video on left side but on mobile it is not responsive. what I've to change here to make it responsive.
<div class="vert_video">
<video width="320" height="540" controls>
<source src="vertical_video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
When i change width to 100% it shows the video on entire screen which looks weird on desktop. help me to make this video responsive.
I think you should add vert_video class to video element.
<div>
<video class="vert_video" controls>
<source src="vertical_video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
Then, add media queries to your css file. In your media queries, you can set max-width or width, which would be useful for you.
/*this query will apply for the devices those have width smaller than 480px*/
#media (max-width: 480px) {
.vert_video {
width: 100%;
height: 100%;
}
}
.vert_video {
width: 75%;
height: 75%;
}
you can use this property in css to set your video's width and height based on device width and length
#media only screen and (max-width: 520px){
/* change the width and height of your video here using video property or the video containing class
it will update the width and height as soon the width of device will go less
than 520px, most of cell phones have width less than 520px(you can change
that too)
*/
}

Scroll disable with content re-sizing

I created a responsive page using HTML and CSS with some screens(including video) viewing by vertical scroll. But on specific window size "960x540", video is not visible completely. I have to scroll down for viewing video.
So I want, if window resize then all content can be adjust according to it without vertical scroll bar.
Better to put your video as responsive. Like -
CSS:
video {
width: 100%;
height: auto;
}
HTML:
<video width="400" controls>
<source src="my_movie.mp4" type="video/mp4">
</video>

Html5 video responsive section

I have a video that I have added to my main section of my site, the dimensions are 1920 x 1080, my problem is that the sides are not 100% width if I make the height 100vh.
if I make the height: 100% it goes past the vh of the browser and the responsiveness is to small.
the way they have this video here is what I am trying to accomplish
http://www.welcometofillory.com/
.container video {
height: 100% !important;
width: 100% !important;
overflow: hidden;
}
<div class="container">
<video id="my-video" preload="auto" loop style="width: 1920px; height: 1080px;" width="100%" height="100%">
<source src="landing-video.mp4" type="video/mp4"></source>
</video>
</div>
What's happening to you is correct since the video will always be enlarged proportionally. If you add it to be 100vh (the entire browswer height) then the sides will go off the canvas as the relation is 16:9.
I recommend you to use bootstrap's responsive video:
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/ePbKGoIGAXY"></iframe>
</div>
Or simply add a wrapper to it that doesn't allow the video to go beyond limits.
.container {
width:100%;
height: 100vh;
overflow: hidden;
}
video{
height: 100vh;
width: auto;
}
Let me know if this helped you, otherwise please add more specifications to your question to understand it better.

Video too small on iPad (height)

Want to show a video in a bootstrap responsive site.
In my CSS file I defined the video tag width to be 100 % of the .span7 box and set the height to auto. Works very well on desktop when I change the width of the browser window. On iPhone it looks very well, too.
Only on iPad the video width is 100 % but height is only about 2 bootstrap rows. That's too small. Why that?
Why is the height so small on iPad in Safari mobile?
This is the trick I use for iPad:
<div class="video">
<canvas width="960" height="540"></canvas>
<video preload="none" width="960" height="540" controls poster="video.jpg">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser does not support the video tag.
</video>
</div>
CSS:
.video {
position: relative;
}
.video video,
.video canvas {
top: 0;
left: 0;
width: 100%;
max-width: 100%;
}
video {
height: 100% !important;
position: absolute;
}
Works like a charm including the preview image (poster).