How to manage CSS Explosion?

Explosion: The CSS explosion basically refers to the explosion of a HTML block when touched or clicked. It is done by equations of motion. It occurs widely in large lines of code. CSS Explosion can’t be prevented completely. It can be reduced by taking up certain measures.

Example: This example uses CSS property to create and manage explosion.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
      
    <!-- CSS style to create explosion -->
    <style>
      
        /* Set the content into center */
        body {
            text-align:center;
        }
          
        /* Set h1 color to green */
        h1 {
            color:green;
        }
          
        /* Set style of container div */
        .container {
            width: 100%;
            background: white;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1;
        }
          
        /* Style to create a div box */
        .exploding-card {
            width: 50%;
            height: 200px;
            border: solid 2px black;
            border-radius: 10px;
            overflow: hidden;
            z-index: 0;
        }
          
        /* Style to create explosion */
        .explosion {
            position: fixed;
            width: 1px;
            height: 1px;
            transform: scale(1);
            border-radius: 80%;
            animation-delay: 0ms;
            background: blue;
        }
          
        /* Style to set animation */
        .exploding-card:active .explosion {
            animation-name: colors;
            animation-duration: 0.75s;
            animation-fill-mode: forwards;
        }
        @keyframes colors {
            0% {
                transform: scale(1);
            }
            100% {
                transform: scale(1000);
            }
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>CSS Explosion</h2>
      
    <div class="container">
        <div class="card exploding-card">
            <div class="explosion"></div>
        </div>
    </div>
</body>
  
</html>                    

chevron_right


Output:

Example 2: This example uses CSS property to create and manage explosion.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
      
    <!-- CSS style to create explosion -->
    <style>
      
        /* Set the content into center */
        body {
            text-align:center;
            background-color:green;
        }
          
        /* Set h1 color to green */
        h1, h2 {
            color:white;
        }
          
        /* Set style of container div */
        .container {
            width: 100%;
            display: flex;
            justify-content: center;
            z-index: 1;
        }
          
        /* Style to create a div box */
        .exploding-card {
            width: 70%;
            height: 200px;
            border: solid 3px white;
            box-sizing: border-box;
            border-radius: 13px;
            overflow: hidden;
            z-index: 0;
        }
  
        /* Style to create explosion */
        .explosion {
            position: fixed;
            width: 2px;
            height: 3px;
            transform: scale(1);
            border-radius: 50%;
            background: white;
        }
          
        /* Style to set animation */
        .exploding-card:active .explosion {
            animation-name: colors;
            animation-duration: 2s;
            animation-fill-mode: forwards;
        }
        @keyframes colors {
            100% {
                transform: scale(1);
            }
            0% {
                transform: scale(1000);
            }
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>CSS Explosion</h2>
      
    <div class="container">
        <div class="exploding-card">
            <div class="explosion"></div>
        </div>
    </div>
</body>
  
</html>                    

chevron_right


Output:



My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.