Fluid-width Google maps

后端 未结 1 517
生来不讨喜
生来不讨喜 2020-12-19 04:58

I have a 2 column layout for the website, with the left fixed-width column and a right fluid-width Google maps that fills the rest of the width not taken by the left column.

相关标签:
1条回答
  • 2020-12-19 05:49

    If you try to use style="width:100%;height:100%" on your map div, as you have done by giving 100% height, you get a map div that has zero height. That's because the div tries to be a percentage of the size of the <body>, but by default the has an indeterminate height.

    There are ways to determine the height of the screen and use that number of pixels as the height of the map div, but a simple alternative is to change the <body> so that its height is 100% of the page. We can do this by applying style="height:100%" to both the <body> and the <html>. (We have to do it to both, otherwise the <body> tries to be 100% of the height of the document, and the default for that is an indeterminate height.)

    Re-adjusting your css values should resolve your issue.

    0 讨论(0)
提交回复
热议问题