Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Forked from magnetikonline/README.md
Created March 24, 2019 23:16
Show Gist options
  • Select an option

  • Save ControlledChaos/da16acb5885cc5e4d18ac62e4c2b7fa4 to your computer and use it in GitHub Desktop.

Select an option

Save ControlledChaos/da16acb5885cc5e4d18ac62e4c2b7fa4 to your computer and use it in GitHub Desktop.
Responsive embedding of Google Maps (or anything <iframe> embedded really).

Responsive Google Maps embedding

A really simple technique for embedding Google Maps <iframe>'s responsively using the handy padding-bottom percentage trick, which when applied to an element will be calculated as a percentage of the element width - essentially an aspect ratio.

This technique should work on anything that is <iframe> embedded from your social network/service of choice.

.container {
height: 0;
overflow: hidden;
padding-bottom: 60%; /* aspect ratio */
position: relative;
}
.googlemap {
border: 0;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
<div class="container">
<iframe
class="googlemap" frameborder="0" scrolling="no"
src="https://maps.google.com.au/maps....&amp;output=embed"></iframe>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment