Last active
December 29, 2015 02:09
-
-
Save kcassam/7598801 to your computer and use it in GitHub Desktop.
Rendre youtube -ou n'importe quel iframe- responsive
This file contains 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
Rendre youtube (ou n'importe quel iframe responsive) | |
HTML : | |
<div class="wrapper"> | |
<div class="h_iframe"> | |
<!-- a transparent image is preferable --> | |
<img class="ratio" src="http://placehold.it/16x9"/> | |
<iframe src="http://www.youtube.com/embed/WsFWhL4Y84Y" frameborder="0" allowfullscreen></iframe> | |
</div> | |
</div> | |
CSS : | |
.wrapper {width:100%;height:100%;margin:0 auto;background:#CCC} | |
.h_iframe {position:relative;} | |
.h_iframe .ratio {display:block;width:100%;height:auto;} | |
.h_iframe iframe {position:absolute;top:0;left:0;width:100%; height:100%;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment