середу, 31 жовтня 2018 р.

Анімація

HTML

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Блок</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="box"></div>
<div class="container">
<div class="bar"></div>
</div>
</body>
</html>



CSS

body{
background: #ccc;
}
.box{
width: 60px;
height: 60px;
background: #333;
margin: 30px;
box-shadow: 0 0 4px rgba(0,0,0,.4);
animation-name: spin;
animation-duration: 2s;
animation-timing-function: linear;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-direction: alternate;
}
.box:hover{
animation-play-state: paused;
}
@keyframes spin{
from{
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
.container{
width: 200px;
height: 30px;
border: 3px solid #fff;
background: #999;
border-radius: 7px;
overflow: hidden;
margin: 40px;
box-shadow: 0 3px 4px rgba(0,0,0,.3);
}
.bar {
width: 400px;
height: 30px;
background: repeating-linear-gradient(45deg,rgba(255,255,255,.9) 0,
rgba(255,255,255,.9) 5px, transparent 5px, transparent 10px);
animation: slide 3s linear infinite;
}
@keyframes slide{
0%{
margin-left: 0;
}
50%{
opacity: 0;
}
100%{
margin-left: -100%;
}
}

Немає коментарів:

Дописати коментар