【发布时间】:2020-01-08 15:31:19
【问题描述】:
在我的 html 代码中,我有两个 div,我想在我的右对齐 65% div 中显示我的地图。我尝试将每个地图的父级高度设置为 100%,并且还遵循文档中的样式,然后我也无法显示地图任何帮助将不胜感激。谢谢
jsfiddle 链接:https://jsfiddle.net/1w5u3t8y/
.row {
height: 100%;
}
.column {
float: left;
height: 100%;
}
.left {
width: 35%;
background: #2193b0;
/* fallback for old browsers */
background: -webkit-linear-gradient(to right, #6dd5ed, #2193b0);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #6dd5ed, #2193b0);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
padding-right: 20px;
}
.right {
background-color: grey;
width: 65%;
}
.card {
width: 450px;
height: 180px;
background-color: #fff;
background: linear-gradient(#f8f8f8, #fff);
box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.4);
border-radius: 6px;
overflow: hidden;
position: relative;
margin: 1.5rem;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#map {
height: 100%;
position: absolute;
}
<div class="row" style="height:100%;">
<div class="column left" />
<div class="column right" style="height:100%;">
<div class="card" id="mapwrapper" style="height:100%;">
<div class="card-header">
Add your Location
<!-- <a href="#" class="btn btn-info float-right ml-3" onclick="submitloc()">Save My Location</a> -->
<input type="text" class="form-control float-right" style="width:300px;" id="location-text-box" placeholder="Enter place to search">
</div>
<div id="map" style="height:100%; width:65%"></div>
</div>
</div>
</div>
【问题讨论】:
-
向我们展示用于初始化地图的 JavaScript。不要包含您的 API 密钥。
-
@Turnip 我添加了jsfiddle链接,由于限制,我无法添加js代码
标签: javascript html css google-maps