【发布时间】:2020-03-29 11:13:59
【问题描述】:
我试图让谷歌地图填写整个内容区域减去固定页眉和固定页脚。
我使用了以下 CSS
.google-maps {width: 100%; height: 100%; margin-left:auto; margin-right:auto;}
.google-maps {position: relative; padding-top: 30px; height: 0; overflow: hidden;}
.google-maps iframe {position: absolute; top: 0; left: 0; width: 100%; height: 100%;}
这个脚本来计算填充底部,这将定义高度:
<script>
var setHeight = function() {
var topHeight = $('.regular-header').outerHeight();
var bottomHeight = $('.sticky-footer').outerHeight();
var contentHeight = $(window).height() - (topHeight + bottomHeight);
$('.google-maps').css({'padding-bottom': contentHeight + 'px'});
}
$(window).load(function() {
setHeight();
});
$(window).resize(function() {
setHeight();
});
</script>
但我觉得我把它复杂化了,也无法让它发挥作用。
我做错了什么?
【问题讨论】:
标签: javascript css google-maps height embedding