Today, we are going to doing an experiment with CSS3 Animation. In our previous post, we discussed how to re-create “marquee” effect using CSS3 Animation. This time, we will try to create a “notification bar” with bounce
HTML
Before we start writing code first, we need to create a primary structure of the HTML document, so that the browser can understand and start working. The basic HTML structure looks like the following.
After writing the primary structure of the HTML document, you will also write the tags and content you need. After that, you can see the output in your browser. We know that HTML Sudu Mae is used for exposing content in a basic format. To complete our content we need to use CSS, which is an HTML insert and it creates an engaging user interface.
<!DOCTYPE html>
<html>
<head>
<title>Bounce Animation</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<h1 class="text">Bounce Animation</h1>
<div class="Bounce"></div>
</div>
</body>
</html>
Now, we have time to improve the HTML content, for that, we need to add CSS to the HTML file. CSS can be added to HTML documents in a total of three ways, here we are using outside CSS design using CSS will arrive here after typing and see the output in your browser.
body{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
background-color: black;
justify-content: center;
align-items: center;
font-family: sans-serif;
}
.text{
color: white;
}
.Bounce{
width: 150px;
height: 150px;
background-color: #c10304;
margin: 70px auto;
border-radius: 50%;
cursor: pointer;
}
.text:hover,.Bounce:hover{
animation: bounce 1s linear;
}
@keyframes bounce{
20%,50%,80%,to{
transform: translateX(0);
}
40%{
transform: translateY(-30px);
}
70%{
transform: translateY(-15px);
}
90%{
transform: translateY(-4px);
}
}
No comments: