在使用 Twitter Bootstrap 样式和 navbar 的页面上,我想要在导航栏下方填充一个 Google Maps 地图以覆盖整个容器。为此,我添加了以下 CSS:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: calc(100% - 40px);
}
我为 html
和 body
元素定义了 100% 的尺寸,这样可以用于地图的尺寸定义。这种解决方案会导致一个问题:
地图的高度现在与整个页面的高度相同,这会导致滚动条可滚动导航栏所增加的 40px。如何将地图的大小设置为导航栏的 100% - 40px
?
#map {
height: 100%;
width: 100%;
}
#map img {
max-width: none;
}
html, body {
height: 100%;
width: 100%;
}
.fill {
height: 100%;
width: 100%;
}
.navbar {
margin-bottom: 0;
}
为了完整性,这是HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!-- Stylesheets -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/core.css">
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
</div>
</div>
<div class="container fill">
<div id="map">
</div>
</div>
</body>
</html>
position: static;
解决它的吗? - Jack Lu