Categories: Development

Make text grow on page load with CSS keyframes

Using CSS keyframe animations on page load can add something extra to your design. Whether it be animating a border, a background change or section grow, using keyframes to change elements with just CSS can be a nice touch.

Here is how to grow text on page load, i am using a h1 element but you can use any typography element.

You can see in the CSS below the animation takes 3 seconds to make the font size 0 to 4rem. There are only 2 keyframes… 0% (the start) and 100% (end).

CSS:

.header-grow {
  animation: growth 3s;
  animation-fill-mode: backwards;
  font-size: 4rem;
}

@keyframes growth {
  0% {
    font-size: 0;
  }
  100% {
    font-size: 4rem;
  }
}

The h1 element:

<h1 class="header-grow">Some heading text</h1>

Gives this result

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago