Skip to content

Instantly share code, notes, and snippets.

@GregJacobs82
Created February 12, 2021 23:21
Show Gist options
  • Save GregJacobs82/c0cdcb3b1299bdc174d1a6f25d9e6d8c to your computer and use it in GitHub Desktop.
Save GregJacobs82/c0cdcb3b1299bdc174d1a6f25d9e6d8c to your computer and use it in GitHub Desktop.
/* Then style the iframe to fit in the container div with full height and width */
.responsive-iframe {
position: relative;
overflow: hidden;
width: 100%;
padding-top: 56.25%; /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */
iframe {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
}
// 4:3 Aspect Ratio
&--4_3 {
@extend .responsive-iframe;
padding-top: 75%; /* 4:3 Aspect Ratio */
}
// 3:2 Aspect Ratio
&--3_2 {
@extend .responsive-iframe;
padding-top: 66.66%; /* 3:2 Aspect Ratio */
}
// 8:5 Aspect Ratio
&--8_5 {
@extend .responsive-iframe;
padding-top: 62.5%; /* 8:5 Aspect Ratio */
}
// 1:1 Aspect Ratio (Height and Width is Always Equal)
&--1_1 {
@extend .responsive-iframe;
padding-top: 100%; /* 1:1 Aspect Ratio */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment