Skip to content

Instantly share code, notes, and snippets.

@GabrielCzar
Last active November 7, 2018 00:13
Show Gist options
  • Save GabrielCzar/50ce81d3ed829fff87c29edd5eb3b4e1 to your computer and use it in GitHub Desktop.
Save GabrielCzar/50ce81d3ed829fff87c29edd5eb3b4e1 to your computer and use it in GitHub Desktop.
Simple css to create an iframe responsive
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.iframe__container {
position: relative;
overflow: hidden;
padding-top: 56.25%;
}
.iframe__responsive {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<h1>TEST IFRAME</h1>
<div class="iframe__container">
<iframe class="iframe__responsive" src="https://www.youtube.com/embed/V_w_KA1VKoQ" frameborder="0" gesture="media"
allow="encrypted-media" allowfullscreen></iframe>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment