Last active
December 25, 2015 04:29
-
-
Save davestewart/6917751 to your computer and use it in GitHub Desktop.
CSS technique to scale media proportionally, even in responsive sites, no server-side code or JS needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* scale video container proportionally to 16:9 */ | |
.video{ | |
width:100%; | |
padding-bottom: 56.25%; | |
position: relative; | |
float: left; | |
height: 0; | |
} | |
/* scale video iframe to 100% */ | |
.video > *{ | |
width:100% !important; | |
height: 100% !important; | |
position: absolute; | |
left: 0; | |
} | |
/* clear the floated container */ | |
.video:after{ | |
clear:both; | |
content:"."; | |
height:0; | |
font-size:0; | |
visibility:hidden; | |
zoom: 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment