How to Implement a Beating Heart Loader in Pure CSS

Avatar

By squashlabs, Last Updated: Jan. 26, 2020

How to Implement a Beating Heart Loader in Pure CSS

Table of Contents

The code below generates a beating heart that can be used as a CSS loader, use it in web pages and web apps.

[bctt tweet="A beating heart (pure CSS) loader." username="LabsSquash"]

 

CSS Code

Preview and Download it here.

@keyframes beating {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.loader {
    position: relative;
    width: 100px;
    height: 90px;
    display: inline-block;
    animation: beating 1s infinite;
}

.loader::before,
.loader::after {
    content: "";
    position: absolute;
    top: 50px;
    width: 52px;
    height: 80px;
    border-radius: 50px 50px 0 0;
    background: red;
}

.loader::before{
    left: 50px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.loader::after{
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

Related Article: How to Right Align Div Elements in CSS

Diagram

Related Article: CSS Padding: An Advanced Guide

More Articles from the Cascading Style Sheets (CSS) Guide series:

How to Center an Absolutely Positioned Element in a Div

Centering an absolutely positioned element in a div can be achieved using various approaches in CSS. This article provides a step-by-step guide on ho… read more

How to Horizontally Center a Div Element in CSS

Centering a div element horizontally in CSS can be achieved using various methods. One solution is to use the "margin: auto;" property, which automat… read more

How to Apply Outline Effect to Text in CSS

Adding an outline effect to text in CSS is a simple process that can enhance the visual appeal of your website. This article provides a step-by-step … read more

How to Hide Scroll Bar in CSS While Maintaining Scroll Functionality

A simple guide on hiding the scroll bar in CSS while maintaining scroll functionality intact. This article covers different methods, including using … read more

How to Set the Transparent CSS Background Color

Setting a transparent background color in CSS is a simple process that can enhance the visual appeal of your website. This article provides a guide o… read more

How to Vertically Align Text in a Div with CSS

This article provides a step-by-step guide on vertically aligning text in a div using CSS. It covers two approaches: using Flexbox and using Table Di… read more

How To Add a Border Inside a Div: CSS Border Inside

Table of Contents Solution 1: Using Padding and Box ShadowSolution 2: Using Border and Background ColorWhy is this question asked and potential reas… read more

How to Fix CSS Text Overflow Ellipsis Issue

Resolving CSS text-overflow ellipsis issues can be frustrating, but it doesn't have to be. This article provides a simple guide to fix this problem b… read more

CSS Position Relative: A Complete Guide

This tutorial is a comprehensive resource that dives deep into the fundamentals, practical examples, real-world applications, and advanced techniques… read more

How to Center an Image in CSS

Learn how to center an image in CSS using easy-to-follow steps. This tutorial covers the basics of CSS centering elements. From understanding the box… read more