gpt4 book ai didi

javascript - 单击按钮时 Google map 不会覆盖整个屏幕

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

代码:

<!DOCTYPE html>
<html>
<head>
<title>Google Maps</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<style type="text/css">
#button {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
height: 50px;
width: 150px;
left: 50%;
top: 50%;
position: absolute;
margin-top: -25px;
margin-left: -75px;
border-radius: 5px;
color: white;
background-color: #4081FB;
font-size: 18px;
border: solid 1px #4081FB;
}
#button:hover {
cursor: pointer;
}
#map {
display: none;
position: absolute;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("#button").click(function () {
$("#map").fadeIn("slow");
});
});
</script>
</head>
<body>
<input type="button" id="button" value="Open Map" />
<div id="map">
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d26496.05743213355!2d151.12773775!3d-33.88946895!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sau!4v1439976442653" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>
</body>
</html>

我不确定为什么当我点击按钮时 Google map iframe 没有覆盖整个屏幕。我已将 iframe 设置为背景大小:封面;单击按钮后覆盖整个屏幕。有人可以帮我弄这个吗?谢谢。

最佳答案

您需要在 #map 上添加高度并更改 iframe 上的内联 css。

  • #map 上添加高度/宽度 (100vh,100vw)
  • 更改 <iframe> 上的内联 html 属性高度/宽度 (100%,100%)

//HTML

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d26496.05743213355!2d151.12773775!3d-33.88946895!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sau!4v1439976442653" width="100%" height="100%" frameborder="0" style="border:0" allowfullscreen></iframe>

//CSS

#map {
height: 100vh;
width: 100vw;

display: none;
position: absolute;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
}

关于javascript - 单击按钮时 Google map 不会覆盖整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32291496/

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