【发布时间】:2019-04-20 19:41:22
【问题描述】:
Edge 可能不想滚动到不可见的东西上。如果锚元素在其父尺寸之外且溢出:隐藏,Edge 浏览器将不会滚动到该位置。
.box {
width: 100%;
height: 100vh;
}
.first {
background-color: red;
}
.second {
background-color: blue;
position: relative;
overflow: hidden;
}
#anchor {
position: absolute;
top: -20px; /* if you change back to 0, anchor will work */
left: 0;
width: 20px;
height: 20px;
background-color: yellow;
}
<div class="box first">
<a href="#anchor">GO TO ANCHOR IN SECOND SECTION</a>
</div>
<div class="box second">
<div id="anchor"></div>
</div>
我需要一个位于其父级之外的锚点,该锚点具有溢出:隐藏,而 href 仍在锚点上滚动。
它在 Chrome 和 Firefox 上运行良好。 边缘版本:44.17763.1.0
【问题讨论】:
标签: html css overflow microsoft-edge