<div id="locateBtn" style="position: absolute; top: 100px; right: 50px; width: 37.5px; height: 37.5px; background: rgb(133, 136, 136); border-radius: 50%; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); cursor: pointer; z-index: 999;"> <div style="position: absolute; top: 13.75px; left: 13.75px; width: 10px; height: 10px; border-radius: 50%; background: #fff;"></div> </div> 请修改为 指向圆点时提示“定位到当前位置”
时间: 2024-03-21 12:40:01 浏览: 45
position:relative/absolute无法冲破的等级
可以尝试修改代码如下所示:
```
<div id="locateBtn" style="position: absolute; top: 100px; right: 50px; width: 37.5px; height: 37.5px; background: rgb(133, 136, 136); border-radius: 50%; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); cursor: pointer; z-index: 999;" title="定位到当前位置">
<div style="position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #fff;"></div>
<div style="position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: #fff;"></div>
<div style="position: absolute; top: 16.25px; left: 16.25px; width: 5px; height: 5px; border-radius: 50%; background: #fff;"></div>
</div>
```
在原有代码的基础上,我们添加了 `title` 属性来设置提示文本。当鼠标指向圆点时,将会提示“定位到当前位置”。
阅读全文