CSS Animation
CSS animations control the movement and appearance of elements
on web pages.
•Use @keyframes to define the animation steps.
•Apply animations with properties like animation-name and
animation-duration.
•Control the animation flow using animation-timing-function
and animation-delay
CSS Animation <!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 4s;
}
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
</style>
</head>
<body>
<h1>CSS Animation</h1>
<div></div>
<p><b>Note:</b> When an animation is finished, it goes back to its
original style.</p>
</body>
</html>
CSS Animation <!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation: mymove 5s infinite;
animation-timing-function: linear;
}
@keyframes mymove {
from {left: 0px;}
to {left: 200px;}
}
</style>
•ease → slow start, faster in middle, slow end. </head>
•ease-in → starts slow, then peeds up. <body>
•ease-out → starts fast, then slows down. <h1>The animation-timing-function Property</h1>
•ease-in-out → slow at start and end, fast in middle. <p>Play an animation with the same speed from beginning to end:</p>
•linear → same speed all along. <div></div>
</body>
</html>
<!DOCTYPE html>
CSS Button <html>
<head>
<style>
.button {
background-color: #04AA6D; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button2 {background-color: #008CBA;} /* Blue */
.button3 {background-color: #f44336;} /* Red */
.button4 {background-color: #e7e7e7; color: black;} /* Gray */
.button5 {background-color: #555555;} /* Black */
</style>
</head>
<body>
<h2>Button Colors</h2>
<button class="button">Green</button>
<button class="button button2">Blue</button>
<button class="button button3">Red</button>
<button class="button button4">Gray</button>
<button class="button button5">Black</button>
</body>
</html>