以下是代码:
div.circle {
height: 134px;
width: 134px;
background-color: #000;
margin: 50vh auto 0;
transform: translateY(-50%);
border-radius: 50%;
animation-name: expand;
animation-duration: 2s;
animation-timing-function: ease-in;
animation-direction: alternate;
animation-iteration-count: infinite;
overflow: hidden;
}
@keyframes expand {
from {height:134px; width: 134px;}
to {height:2000px; width:2000px;}
}
<div class="circle"></div>
当圆圈变得大于窗口时,窗口变为可滚动,滚动鼠标时会出现滚动条。使用overflow:hidden
无法阻止此..
当元素变得比窗口大时,有没有人有关于如何隐藏滚动条并锁定窗口的想法?
答案 0 :(得分:1)
overflow:hidden
如果您将其应用于body
而不是您的圈子
body {
overflow: hidden;
}
div.circle {
height: 134px;
width: 134px;
background-color: #000;
margin: 50vh auto 0;
transform: translateY(-50%);
border-radius: 50%;
animation-name: expand;
animation-duration: 2s;
animation-timing-function: ease-in;
animation-direction: alternate;
animation-iteration-count: infinite;
overflow: hidden;
}
@keyframes expand {
from {height:134px; width: 134px;}
to {height:2000px; width:2000px;}
}
<div class="circle"></div>