Home >Web Front-end >CSS Tutorial >How to create a call animation effect using CSS?

How to create a call animation effect using CSS?

WBOY
WBOYforward
2023-09-02 16:01:021641browse

How to create a call animation effect using CSS?

Cascading Style Sheets (CSS) Enables developers to create visual effects for your web pages, making them attractive and user-friendly. CSS provides various properties such as colors, flexbox, grid, animations, shadows, etc. to style elements to form a website that is attractive and user-friendly to many users.

In this article, we discussed how to design animatronic effects using HTML and CSS. To create this effect, we will use CSS animation properties and the box-shadow property.

CSS animation

It enables developers to add animation effects, such as movement, vibration, etc., to our web pages to increase aesthetic value.

grammar

animation: animation-name | animation-duration | speed; 

CSS Box-shadow Property

It enables developers to provide dark shades on one side and light shades on the other side.

grammar

box-shadow: values;

The value of this attribute is -

  • None - No shadow is displayed on the element. It's the default value.

  • Offset-X − The distance of the shadow from the element in the horizontal direction. Positive values ​​for offset-X will cast a shadow on the right side of the element, while negative values ​​will cast a shadow on the left side of the element.

  • Offset-Y − Controls the vertical distance of the shadow from the element. Positive values ​​place the shadow above the element, negative values ​​place the shadow below the element.

  • Blur Radius - It specifies the sharpness of the shadow. The higher the number, the blurrier the shadow, meaning it will be larger and brighter

  • Spread- radius - It specifies the size of the shadow. If its value is positive, the size increases. If negative, the size is reduced.

  • Color - It specifies the color of the shadow.

  • Inset − It enables developers to create shadows so that the content of an element appears to be below the border. Therefore, a shadow is created within the border.

The Chinese translation of

Example

is:

Example

<!DOCTYPE html>
<html>
<head>
   <style>
      #demo {
         border: 5px solid;
         padding: 10px 15px;
         box-shadow: -5px -10px 0px 5px yellow;
      }
   </style>
</head>
<body>
   <h1>The box-shadow property</h1>
   <article id="demo">
      <p>This is an article element with a shadow. It contains four values that are offset-X (horizontal distance), offset-Y (vertical distance), spread radius and color. </p>
   </article>
</body>
</html>

Create call animation effects

In the example below, we try to display a phone ring icon using CSS Font Awesome icons.

Then, we have used the box-shadow property and CSS animations to create the ringing effect. In order to control the sequence of animation, we have used @keyframes

The Chinese translation of Example

is :

Example

<!DOCTYPE html>
<html>
<head>
   <title>Incoming Call Animation</title>
   <link rel="stylesheet" href= "https://pro.fontawesome.com/releases/v5.10.0/css/all.css">
   <style>
      body{
         height: 80%;
         margin: 10px;
         padding: 0;
         display: flex;
         align-items: center;
         justify-content: center;
         background: black;
      }
      section{
         position: absolute;
         top: 10%;
         display: flex;
         justify-content: center;
         align-items: center;
         border: 2px solid orange;
         height: 65%;
         width: 40%;
      }
      .call{
         position: relative;
         background: black;
         color: orange;
         font-size: 35px;
         font-weight: bold;
         width: 70px;
         height: 70px;
         border-radius: 100%;
         border: solid 5px black;
         animation: anim 2s ease-in infinite, vibration 2s ease-in infinite;
      }
      .img{
         position: absolute;
         top: 20px;
         left: 20px;
         height: 60px;
         width: 50px;
      }
      @keyframes anim {
         0% {
            box-shadow: 0 1px 0 4px #ffffff;
         }
         10%{
            box-shadow: 0 1px 0 8px rgba(255, 165, 0, 1);
         }
         25% {
            box-shadow: 0 1px 0 12px rgba(255, 210, 128, 1), 0 1px 0 16px rgba(255, 201, 102, 1);
         }
         50% {
            box-shadow: 0 2px 5px 10px rgba(255, 184, 51, 1),  0 2px 5px 23px rgba(248, 248, 255, 1);
         }
      }
      @keyframes vibration {
         0% { transform: rotate(0deg); }
         25% { transform: rotate(20deg); }
         50% { transform: rotate(0deg); }
         75% { transform: rotate(-15deg); }
         100% { transform: rotate(0deg); }
      }
   </style>
</head>
<body>
   <section>
      <div class= "call">
         <i class= "fas fa-solid fa-phone img"> </i>
      </div>
   </section>
</body>
</html>

The incoming call icon will be displayed on the web page and the ringing effect will be observed by the animation effect.

in conclusion

Customers in the modern technology market require more website participation. At this point, animation plays a vital role in improving communication. The interactive nature of animation encourages user interaction and improves user experience. If you want your website to stand out from the competition and be loved by your target audience at the same time, then hiring a top website development company to add animations to your website will be helpful.

The above is the detailed content of How to create a call animation effect using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete