Чтобы overflow: hidden
работал на main
, вам нужно установить position: relative
и height
:
*,
*::after,
*::before {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
main {
position: relative;
height: 100vh;
overflow: hidden;
}
.ball {
background-color: #eb8c28;
width: 100px;
height: 100px;
border-radius: 0%;
position: absolute;
bottom: 0%;
left: 50%;
animation: rise;
animation-duration: 2s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
@keyframes rise {
0% {
border-radius: 50%;
}
50% {
border-radius: 50%;
transform: translateY(-100%);
}
75% {
border-radius: 40%;
}
80% {
border-radius: 30%;
}
90% {
border-radius: 20%;
}
100% {
transform: scale(20, 20);
}
}
<main>
<div class="ball"></div>
</main>
Или вы можете установить overflow: hidden
на теле:
*,
*::after,
*::before {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
overflow: hidden;
}
.ball {
background-color: #eb8c28;
width: 100px;
height: 100px;
border-radius: 0%;
position: absolute;
bottom: 0%;
left: 50%;
animation: rise;
animation-duration: 2s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
@keyframes rise {
0% {
border-radius: 50%;
}
50% {
border-radius: 50%;
transform: translateY(-100%);
}
75% {
border-radius: 40%;
}
80% {
border-radius: 30%;
}
90% {
border-radius: 20%;
}
100% {
transform: scale(20, 20);
}
}
<main>
<div class="ball"></div>
</main>
Кроме того, рекомендуется установить transform: translateY
в относительное значение, чтобы его можно было масштабировать для разных размеров экрана, т.е. transform: translateY(-100%)