Published on: 24 March, 2016

Create Heart beating using CSS3 Animation

Posted by andy | 2552 views 6 likes 7 favourites 0 comments
Tumblr Digg Google Plus

You probably never thought about creating a heart shape completely using CSS3. Furthermore, you can include an animation to show the heart is actually beating. This is can be easily done with CSS3 animation. No flash or images are required.

Below is the css style code required to create the heart shape with beating animation in CSS3.

.heart-shape {
	position: relative;
	width: 50px;
	-webkit-animation: heart-beats 3s infinite;
	animation: heart-beats 3s infinite;

.heart-shape:after {
   background: #fd3803;
   position: absolute;
   width: 22px;
   height: 35px;
   top: 0;
   left: 22px;
   content: '';
   border-radius: 50px 50px 0 0;
   transform: rotate(-45deg) translateZ(0);
   -webkit-transform: rotate(-45deg) translateZ(0);
   transform-origin: 0 100%;
   -webkit-transform-origin: 0 100%;

.heart-shape:after {
   left: 0;
   transform: rotate(45deg) translateZ(0);
   -webkit-transform: rotate(45deg) translateZ(0);
   transform-origin :100% 100%;
   -webkit-transform-origin: 100% 100%;

@keyframes heart-beats {
  0%   { transform: scale(1); background-color:black;}
  7%  { transform: scale(1.2); }
  12%  { transform: scale(1.1); }
  20%  { transform: scale(1.3); }
  60%  { transform: scale(1); }
  100% { transform: scale(0.99); }

@-webkit-keyframes heart-beats {
  0%  { -webkit-transform: scale(1); }
  7%  { -webkit-transform: scale(1.2); }
  12% { -webkit-transform: scale(1.1); }
  20% { -webkit-transform: scale(1.3); }
  60% { -webkit-transform: scale(1); }
  100% { -webkit-transform: scale(0.99); }

Here is the html code required to create the heart shape. Basically just a div tag with a heart-beat css class on it.

<div class="heart-shape"></div>	

Demo of Heart Beating using CSS3 Animation


There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.
Share your article with us and add your own google adsense account to earn extra money. Plus, you can promote a link back to your site.
Related Articles
Published on: 20 January, 2018
By default, a table in HTML will contain a default value of cellpadding and cellspacing. This can be easily removed if you are using tag properties attached to the HTML table itself. For example, you can see the following image. I have included a border to the table so we can exactly see the cellpadding and cellspacing applied to the table.
Published on: 13 July, 2016
Ever imagine that you can now easily create a bouncing ball using CSS3 only? No javascript or image is required to do this. Thanks to the powerful attribute of CSS3 animation.
Related Tutorials
Published on: 28 June, 2014
Learn how to use media queries in CSS3. Media queries are simple conditions used to targetting different devices for tables, phones or desktop computers. As each device may have different view size, media queries become so handy to use to display the content dimension correctly.
Published on: 28 June, 2014
Learn how to use advanced selectors in CSS3. By using the built in pseudo-class, performing a selector in CSS3 is so much easy.
Published on: 14 May, 2014
Learn how to use multiple-column property in CSS3. To create multiple columns in CSS3 is now so handy, you just need to include a css built-in keyword column-count to do the job for you. No more table layout required.
Published on: 13 May, 2014
Learn how to use box-sizing property in CSS3. As you know many browsers treat margin and padding differently. When you combine with width or height of an element box, you find out that the final dimension is completely different when you view with different browser. Well, this now can be easily taken care by using the new CSS box-sizing property.
Published on: 09 May, 2014
Learn how to use opacity property in CSS3. So what is actually opacity? CSS3 Opacity defines a transparency level of an element. The property value of opacity is range from 0 to 1.