Assad Nazar
Assad Nazar

Reputation: 1464

Responsive Embedded Google Maps

So, I know the responsive behavior shown by many of the community members as:

HTML

<div class="map-responsive">
    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d15288.360926048195!2d51.52175762195133!3d25.282422800605804!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3e45c534ffdce87f%3A0x1cfa88cf812b4032!2sQatar!5e0!3m2!1sen!2s!4v1546430525796" width="380" height="440" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>

and css

.map-responsive{
    overflow:hidden;
    padding-bottom:56.25%;
    position:relative;
    height:0;
}
.map-responsive iframe{
    left:0;
    top:0;
    height:100%;
    width:100%;
    position:absolute;
}

What i am trying to do is having a bootstrap 2 column layout where 1st column has an image and 2nd column has the map. and the issues are:

  1. equal height
  2. Responsive behavior

Here is the code

<div class="container-fluid px-0">
<div class="row mx-0">
    <div class="flex-grow-0">
        <img class="img-fluid" src="https://devs.kodenlogix.com/mtmgrp/mtmglobal/wp-content/uploads/2019/01/contactus-img.jpg" alt="Contact">
    </div>
    <div class="flex-grow-1 map-responsive">
        <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d15288.360926048195!2d51.52175762195133!3d25.282422800605804!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3e45c534ffdce87f%3A0x1cfa88cf812b4032!2sQatar!5e0!3m2!1sen!2s!4v1546430525796" width="380" height="440" frameborder="0" style="border:0" allowfullscreen=""></iframe>
    </div>
</div>

For a reference, here is the page i am working on: Sample

Upvotes: 4

Views: 5290

Answers (1)

Shingai Munyuki
Shingai Munyuki

Reputation: 611

Try this. Change the width to 100% in the iframe, and remove height:100%; from .map-responsive iframe

<iframe src="https://www.google.com/maps/embed? pb=!1m18!1m12!1m3!1d15288.360926048195!2d51.52175762195133!3d25.282422800605804!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3e45c534ffdce87f%3A0x1cfa88cf812b4032!2sQatar!5e0!3m2!1sen!2s!4v1546430525796" width="100%" height="440" frameborder="0" style="border:0" allowfullscreen=""></iframe>

Take a look at the code on this JSFIDDLE, i'm, not using your css at all.

Upvotes: 7

Related Questions