Responsive Web Design - Video
Using the width property
If the width property is set to 100%, the video player will automatically adjust its proportions according to the screen size:
Example
video
{
width:
100%;
height:
auto;
}
Try it »
Note that in the example above, the video player automatically adjusts its proportions according to the screen size and can be larger than its original size. In most cases, we can use the max-width property instead.
Using the max-width property
If the max-width property is set to 100%, the video player will automatically adjust its proportions according to the screen, but will not exceed its original size:
Example
video
{
max-width:
100%;
height:
auto;
}
Try it »
Adding video to a web page
We can add video to a web page. In the following example, the video automatically adjusts according to the size of the div area and fills the entire div area:
Example
video
{
width:
100%;
height:
auto;
}
Try it »