0xjustuzair
0xjustuzair

Reputation: 587

Hide CSS Animation's content overflow

I have been trying to make an animation and have almost completed it. The only problem I'm facing is that the horizontal and vertical scrollbars aren't hiding. I tried adding overflow:hidden property to parent div i.e. .box but still I'm not able to hide them.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      
      .box {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
      }
      .rotor1 {
        height: 100vw;
        background: rgb(152, 227, 250);
        animation: 9.2s keepRotating infinite ease-in-out;
        z-index: 3;
      }
      .rotor2 {
        height: 102vw;
        background: rgb(204, 238, 248);
        border-radius: 30%;
        animation: 9.05s keepRotating infinite ease-in-out;
        animation-timing-function: linear;
      }
      .rotor1,
      .rotor2 {
        width: 110vw;
        position: absolute;
        top: -78vw;
        border-radius: 30%;
        animation-timing-function: linear;
      }

      @keyframes keepRotating {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="rotor1"></div>
      <div class="rotor2"></div>
    </div>
  </body>
</html>

Is there a way to hide both the horizontal and the vertical scrollbars??

Upvotes: 0

Views: 44

Answers (1)

ATP
ATP

Reputation: 3249

Use overflow: hidden; on body

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
         body{
          overflow: hidden;
          }
        .box {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
      }
      .rotor1 {
        height: 100vw;
        background: rgb(152, 227, 250);
        animation: 9.2s keepRotating infinite ease-in-out;
        z-index: 3;
      }
      .rotor2 {
        height: 102vw;
        background: rgb(204, 238, 248);
        border-radius: 30%;
        animation: 9.05s keepRotating infinite ease-in-out;
        animation-timing-function: linear;
      }
      .rotor1,
      .rotor2 {
        width: 110vw;
        position: absolute;
        top: -78vw;
        border-radius: 30%;
        animation-timing-function: linear;
      }

      @keyframes keepRotating {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="rotor1"></div>
      <div class="rotor2"></div>
    </div>
  </body>
</html>

Upvotes: 1

Related Questions