我希望在我的Leaflet地图的右上角(距离顶部和右侧20像素)添加一个按钮。问题是我不确定如何正确地实现这一点。问题在于当我使用"leaflet-top leaflet-right"类时,我的按钮无法点击,并且当我将鼠标悬停在其上时,没有任何反应。它只是保持为地图的一部分。
以下是我的HTML代码:
这里是我的CSS:
以下是我的HTML代码:
<div id="mainContainer">
<div id="mapDiv">
<div id="map">
<div class="leaflet-top leaflet-right">
<div id="refreshButton"><div id="refreshButtonPictogram"><img src="pictograms/refresh.png" height="30px"></div></div>
</div>>
</div>
</div>
<div id="bars"></div>
</div>
这里是我的CSS:
#mainContainer{
position: relative;
width: 100%;
height: calc(100% - 80px);
display: flex;
}
#bars{
z-index: 0;
width: 500px;
overflow-x: auto;
border-left: 1px solid rgb(214, 49, 65);
}
::-webkit-scrollbar {
display: none;
}
#mapDiv {
flex: 1;
}
#map {
width: 100%;
height: 100%;
z-index: 0;
}
#refreshButton{
display: flex;
align-items: center;
position: relative;
top: 20px;
right: 20px;
width: 50px;
height: 50px;
background-color: white;
border-radius: 5px;
border-color: gray;
border-style: solid;
border-width: 1px 1px 1px 1px;
opacity: 0.6;
text-align: center;
}
#refreshButton:hover{
opacity: 0.8;
cursor: pointer;
}
#refreshButtonPictogram{
margin: auto;
}
@media screen and (max-width: 500px) {
#mainContainer {
flex-direction: column;
}
#mapDiv,
#bars {
flex: 1;
}
}