gpt4 book ai didi

javascript - Google Maps Javascript API 忽略输入字段的 CSS

转载 作者:行者123 更新时间:2023-11-28 17:11:10 24 4
gpt4 key购买 nike

加载 map 后,我的 CSS 被忽略 <#map .map-control1/#map .map-control2>。

我意识到没有办法用纯 CSS 设置参数。

那我该如何解决呢?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#map {height: 100%;}
#map .map-control1 {top: 0px;}
#map .map-control2 {top: 50px;}
#origin-input, #destination-input {text-overflow: ellipsis;}
</style>
</head>
<body>
<input id="origin-input" class="map-control1" type="text"
placeholder="Origin">
<input id="destination-input" class="map-control2" type="text"
placeholder="Destination">
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeControl: false,
center: {lat: -23.0013, lng: -43.3861},
zoom: 17
});
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=_dsdsds&callback=initMap"
async defer></script>
</body>
</html>

最佳答案

.map-control 是从 #map 级联而来的。像这样删除它以获得所需的样式。

.map-control1 { /* without #map */
top: 0px;
}

.map-control2 { /* without #map */
top: 50px;
}

关于javascript - Google Maps Javascript API 忽略输入字段的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45686583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com