Google Maps with Bootstrap not responsive

前端 未结 9 689
予麋鹿
予麋鹿 2021-01-30 02:11

I\'m using bootstrap and I embedded Google Maps API 3.

#map_canvas isn\'t responsive; it\'s a fixed width.

Also, if I use height: auto

9条回答
  •  迷失自我
    2021-01-30 02:47

    This blog post has a great solution.

    Add a div tag around the embed code. Use the CSS class map-responsive so that your code now looks like this:

    Now add some CSS properties inside one of your stylesheet files:

    .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;
    }
    

提交回复
热议问题