Skip to content

Instantly share code, notes, and snippets.

@karuna24s
Created February 11, 2017 17:43
Show Gist options
  • Save karuna24s/766f1d0fb42337f10557496b877e382d to your computer and use it in GitHub Desktop.
Save karuna24s/766f1d0fb42337f10557496b877e382d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=766f1d0fb42337f10557496b877e382d
<!DOCTYPE html>
<html>
<head>
<title>Heart</title>
</head>
<body>
<div class='container'>
<div class='heart'></div>
</div>
<p>Example from <a href="https://robots.thoughtbot.com/css-animation-for-beginners">CSS Animation for Beginners by Rachel Cope</a>, December 04, 2014</p>
</body>
</html>
.container {
margin: 100px auto;
padding: 100px;
position: relative;
transform: rotate(45deg);
width: 100px;
}
.heart {
background: salmon;
height: 100px;
position: relative;
width: 100px;
animation-name: heartBeat;
animation-duration: 3s;
animation-iteration-count: infinite;
}
.heart:before {
background: salmon;
border-radius: 50%;
content: "";
height: 100px;
position: absolute;
top: -50px;
width: 100px;
}
.heart:after {
background: salmon;
border-radius: 50%;
content: "";
height: 100px;
left: -50px;
position: absolute;
width: 100px;
}
@keyframes heartBeat {
0% {
transform: scale(1);
-webkit-transform: scale(1);
}
20% {
transform: scale(1.2);
-webkit-transform: scale(1.2);
}
30% {
transform: scale(1.05);
-webkit-transform: scale(1.05);
}
45% {
transform: scale(1.25);
-webkit-transform: scale(1.25);
}
50% {
transform: scale(1.25);
-webkit-transform: scale(1.25);
}
100% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
@-webkit-keyframes heartBeat {
0% {
transform: scale(1);
-webkit-transform: scale(1);
}
20% {
transform: scale(1.2);
-webkit-transform: scale(1.2);
}
30% {
transform: scale(1.05);
-webkit-transform: scale(1.05);
}
45% {
transform: scale(1.25);
-webkit-transform: scale(1.25);
}
50% {
transform: scale(1.25);
-webkit-transform: scale(1.25);
}
100% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
p {
font-family: arial;
font-size: 12px;
position: absolute;
bottom: 0px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment