【发布时间】:2022-01-19 23:17:07
【问题描述】:
我有一个动画 div,它飞到视口的右上角。
但是,由于 overflow 属性,它在 Firefox 的父容器之外不可见。它在 Chrome 中完全可见。
Firefox 中滚动条后面的元素:
Chrome 中父元素的正确上方:
如何让它在 Firefox 中也能正常工作?如果从.container 中删除overflow-y: auto,则问题不会再出现,但这不是一个可行的解决方案,因为我需要可滚动的内容。
这是一个例子。您可以检查它是否在 Chrome 中产生了所需的行为,但在 Firefox 中却没有:
.app {
overflow: hidden;
}
.container {
width: 260px;
max-height: 400px;
background: blue;
left: 10px;
right: 10px;
top: 10px;
position: fixed;
z-index: 500;
overflow-y: auto;
}
.wrapper {
height: 250px;
padding: 10px;
margin: 5px;
background: yellow;
top: 5px;
position: sticky;
}
.content {
height: 600px;
margin: 5px;
background: orange;
}
@keyframes fly-to-top {
10% {
top: 150px;
right: 80%;
width: 50px;
}
30% {
top: 120px;
right: 70%;
width: 45px;
}
60% {
top: 75px;
right: 40%;
width: 40px;
}
100% {
top: 10px;
right: 160px;
width: 35px;
}
}
.animated {
position: fixed;
right: unset;
top: 165px;
width: 50px;
background: red;
color: white;
animation: fly-to-top linear 2s forwards;
display: flex;
align-items: flex-start;
}
<div class="app">
<div class="container">
<div class="wrapper">
<div class="animated">
Text
</div>
</div>
<div class="content">
Lorem ipsum
</div>
</div>
</div>
【问题讨论】:
标签: html css firefox css-animations css-position