Forum Moderators: open
[edited by: travelin_cat at 1:21 pm (utc) on Apr 22, 2015]
[edit reason] Removed url [/edit]
The concept
The idea is to create a box with the proper ratio (4:3, 16:9, etc.), then make the video inside that box stretch to fit the dimensions of the box. It's that simple.
The trick
The padding property is the magic that styles a box with an intrinsic ratio. This is because we'll set padding in a percentage, based on the width of the containing block....
A few HTML elements don't play nice with responsive layouts. One of these is the good ol' iframe, which you may need to use when embedding content from external sources such as YouTube.
In this article, we'll show you how to make embedded content responsive using CSS, so that content such as video and calendars resize with the browser's viewport. For those occasions when non-coders will be embedding video on your website and you don't want to rely on them adding extra markup, we'll also look at a solution that uses JavaScript instead of CSS....