Google Maps iframe width="100%" not working in Chrome

Viewed 7736

I'm using an iframe to import a Google map to my website.

I'm using this code:

HTML
<div class="iframe-maps">
    <iframe src="https://www.google.com/maps/d/embed?mid=1Z_DcQ-f4EdnEwL6sRKfLCYCj5P8&hl=en" width="100%" height="100%"></iframe>
</div>

and:

CSS
.iframe-maps {
    width: 80%;
}

I added the iframe inside a div as recommended on another thread, but it didn't budge.

This is working perfectly in Firefox (mobile and desktop) and Edge (same) though but not in Chrome. I don't know about Safari though. This seems pretty straitgh forward. Is there anything I'm missing here?

This only think I found about this issue is this: https://www.experts-exchange.com/questions/26706977/Iframe-auto-height-display-problem-in-Safari-Chrome.html but it's from 2010... and I suppose this issue has been fixed a long time ago?

2 Answers

width:80% (80% of parent width) works only if parent has defined width - as length or as percent. That's by CSS specification.

Check parent of your .iframe-maps as I am pretty sure it has something as width:auto or not defined at all.

Try like this

 .iframe-maps iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }

 .iframe-maps iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
    }
<div class="iframe-maps">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3168.6391103405977!2d-122.0862461843548!3d37.422004140149184!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x808fba02425dad8f%3A0x6c296c66619367e0!2sGoogleplex!5e0!3m2!1sen!2slk!4v1544010623115" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>

Related