我有這個例子(click here)其中即時試圖使谷歌地圖的高度動態調整到旁邊的跨度。調整谷歌地圖高度動態在行
任何幫助非常感謝。
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<style>
#map {
width: 500px;
height: 400px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="span8">
<p>This is something dynamic and longer than the map.</p>
<p>I want the map to adapt to this span</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>N/A</p>
<p>MAP'S HEIGHT SHOULD BE LAST TILL HERE AND <b>NOT</b> SPECIFIED WITH <b>FIXED</b> HEIGHT</p>
</div>
<div class="span4">
<div id="map"></div>
</div>
</div>
</div>
<script>
function initMap() {
var mapDiv = document.getElementById('map');
var map = new google.maps.Map(mapDiv, {
center: {lat: 44.540, lng: -78.546},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap"
async defer></script>
</body>
</html>
常見的解決方案是行不通的。
html, body{
height: 100%;
}