Skip to content

Instantly share code, notes, and snippets.

@kcassam
Last active December 29, 2015 02:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kcassam/7598801 to your computer and use it in GitHub Desktop.
Save kcassam/7598801 to your computer and use it in GitHub Desktop.
Rendre youtube -ou n'importe quel iframe- responsive
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