I have a video on one of my html pages, and I love the dimensions for it on desktop, but on mobile its way too large, and is extending the screen.
I know this is fixable but I'm a bit confused in the solution I've looked a few up and am still confused.
<video width="900" height="450" autoplay loop controls >
<source src="images/Demo.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
video{
max-width:900px;
width:100%;
}
<video height="450" autoplay loop controls >
<source src="images/Demo.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
below CSS might help you.
video{
max-width:900px;
width:100%;
}
Remove the width and height attributes inside the HTML.
<video autoplay loop controls >
<source src="images/Demo.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
Use CSS media queries to style the video frame. Example:
#media only screen and (max-width: 600px) {
video {
width: 900px;
height: 450px;
}
}
See the first line of the CSS code. There stands max-width: 600px. This is the maximal width of your screen. 600px are small devices.
Disclaimer: the CSS code is pseudo code. Play with the numbers to fit it into your screen and for mobile use percentage instead of pixels.
If you use width: 100%; it will be responsive to any screen size.
Using the CSS code multiple times with other screen sizes, you could support tablet or computer screens.
P.S.: Use mp4 files instead of mov files. It's more widely supported by the browsers.
Related
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)
*/
}
I have a <video> tag in my HTML, that looks like this:
<video control>
<source src="[video_url].webm" type="video/webm">
<source src="[video_url].mp4" type="video/mp4">
<p>Your browser does not support this type of video</p>
</video>
This video is hosted on Cloudinary, and I'm doing an inline transform with the src to get a specific dimension (w_450,h_350).
The video by itself looks fine, however I have a media query where I shrink the video by 100px in both width and height to fit smaller screen sizes
#media screen and (max-width: 1000px) {
video { width: 350px; height: 250px }
}
And as you can see, the video container has a shadow that overflows past the width and height of the new container size. If I click play on the video, the box shadow persists.
How do I make the box-shadow for the controls fit the actual size of the container?
Rather than applying height width to the tag you should enclose it within a
<div>
<video control>
<source src="[video_url].webm" type="video/webm">
<source src="[video_url].mp4" type="video/mp4">
<p>Your browser does not support this type of video</p>
</video>
</div>
And then apply your css to the
#media screen and (max-width: 1000px)
{
div{ width: 350px; height: 250px }
video{ width: 100%; height: 100% }
}
Assuming that the poster size of an HTML 5 video should always be 16:9 but the height of the actual video is still auto. How can I make the poster image stick to those dimensions (it shall be cutted to fit the dimensions e.g. with object-fit)?
video {
width:100%;
height:auto;
}
video[poster] {
width:100%;
}
<video poster="https://i.imgur.com/LFgR8jD.png" controls="controls" class="pimcore_video" preload="none">
<source type="video/mp4" src="https://storage.coverr.co/videos/sksZ7cBoTBAJkB4Bul46QAI1c01x7lx18?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6IjExNDMyN0NEOTRCMUFCMTFERTE3IiwiaWF0IjoxNTg3MDMwNzIwfQ.moAIavql_5_ggd9hrKExX6iPeo2UM_CMya6Mozg4hyY">
</video>
As you can see in the snippet above the size of the poster image is different to the video itself.
So I'm trying to make this website with a video for the banner, now it works perfectly in Firefox (my primary browser) but whenever I run it in chrome the video doesn't resize and covers the navigation menu. I haven't yet tried this in edge so I can't say yet how it works there but I need it to work in Firefox and Chrome mainly.
I'm using an unedited .mp4 video in a code block like so
<header class="main-header">
<video autoplay muted loop id="myVideo">
<source src="images/hotel.mp4" type="video/mp4">
</video>
</header>
And the css,
#myVideo {
position: relative;
bottom: 100;
object-fit: cover;
width:100%;
height:100%;
}
I can add the entire code block from the home-page is that helps.
I am trying to make my video a responsive one. The video has been positioned on top of an image (a tv screen) and it is important that it stays in the same place no matter how big the browser.
How would I go about making the video so it is
a) responsive
b) fixed in the position it is currently in.
The video has a height and a width so I am guessing it is harder to do.
Any advice would be appreciated.
Thanks
Reece
<div class="videocontainer">
<h1 class="videosheading"><strong>VIDEOS</strong></h1>
<div class="row">
<div class="col-xs-12 video-cell">
<img class="img-responsive" src="img/TVWALLTWO.jpg"/>
<video width="550" height="422" controls muted>
<source src=http://techslides.com/demos/sample-videos/small.webm type=video/webm>
<source src=http://techslides.com/demos/sample-videos/small.ogv type=video/ogg>
<source src=http://techslides.com/demos/sample-videos/small.mp4 type=video/mp4>
<source src=http://techslides.com/demos/sample-videos/small.3gp type=video/3gp>
</video>
</div>
</div>
</div>
.video-cell {
position: relative;
}
.video-cell img {
width: 100%;
}
.video-cell video {
position: absolute;
top:6%;
bottom:10%;
left: 0;
right: 7%;
background-color: black;
border: #2F2925 10px solid;
border-radius: 10px;
margin: auto;
max-width: 100%;
}
Making a video responsive is pretty much the same as making a picture responsive.
Mainly, you have 2 solutions:
1) Using width and max-width properties in %s instead of pixels.
The video will scale within his limits (and of course within the window limits).
This is a very common solution - but nevertheless, I do NOT suggest you use it.
This might not look good on screens that are in different aspect-ratio than your video.
http://www.w3schools.com/css/css_rwd_videos.asp
2) The better solution to your problem is using the media attribute for your source, adjusting different videos for different screen sizes (media queries).
<video>
<source src="video-widescreens" media="screen and (min-width:800px)">
<source src="video-widescreens" media="screen and (min-width:800px)">
<source src="video-smallscreens.mp4" media="screen and (max-width:799px)">
<source src="video-smallscreens" media="screen and (max-width:799px)">
</video>