Open In App

How to define the shape of the corners is animatable using CSS ?

Last Updated : 24 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The task is to animate the shape of all corners using the CSS.  Cascading Style Sheets(CSS) is a language used to give style to the web page. The shape of corners can be defined and animated using CSS by utilizing the "border-radius" property. By specifying a value for "border-radius" in conjunction with CSS animations or transitions, the corners of an element can be dynamically transformed and animated.

Properties:

In this article, we will make use of the following properties

Approach:

The first task is to create the basic HTML page structure with the style element. After creating the style tag into the head tag, we will add the border-bottom-right-radius, border-bottom-left-radius, border-top-left-radius, border-top-right-radius properties to style all the corners and also provide the animation with the help of the animation property.

Example:  In this example, we are using the above-explained approach.

HTML
<!DOCTYPE html>
<html>

<head>
  <style>
    body {
      text-align: center;
    }

    h2 {
      margin-left: 10px;
      margin-top: 30px;
      margin-right: 15px;
      background-color: lightgreen;
      border: 5px solid green;
      height: 100px;

      animation: mymove 5s infinite;
    }

    @keyframes mymove {
      60% {
        border-bottom-right-radius: 60px;
        border-top-left-radius: 60px;
        border-top-right-radius: 60px;
        border-bottom-left-radius: 60px;
      }
    }
  </style>
</head>

<body>
  <h2>GeeksforGeeks</h2>
</body>

</html>

Output:

animations

Next Article

Similar Reads