CSS ResponsiveLesson #197

RWD Videos

If the `width` property is set to 100%, the video player will be

Using The width Property

If the width property is set to 100%, the video player will be responsive and scale up and down:

Example

Example Code

css
Try it Yourself
video {

  width: 100%;
  height: auto;

}

Notice that in the example above, the video player can be scaled up to be larger than its original size. A better solution, in many cases, will be to use the max-width property instead.


Using The max-width Property

If the max-width property is set to 100%, the video player will scale down if it has to, but never scale up to be larger than its original size:

Example

Example Code

css
Try it Yourself
video {

    max-width: 100%;
  height: auto;

}

Add a Video to the Example Web Page

We want to add a video in our example web page. The video will be resized to always take up all the available space:

Example

Example Code

css
Try it Yourself
video {

    width: 100%;
  height: auto;

}


Interactive Code Examples

CSS Example 1

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 2

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 3

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview: