Text Transition with pure CSS




Most of the websites use text transition or fading text in and out using the bootstrap. More of the coders does not know the internal working of the text transition. It is just simple to make changing text only by using the css. Text transition can ne made using the animation that uses @keyframes property and a property content. First we set the content of the h1 to null value the we add the content using the property content using css.

Here is the live preview of the code:

Live Preview:







The contents that given here has fixed time delays between them. Here I added the content inside the h1 tag but you can also give the contents inside any type of tag that can also be a P tag. The time delay of the changing text canbe changed using the attribute transition having a value related to time that can be in seconds.

The code of the text trasition is as follows:

Code:


<html>
    <style>
   
    .h:before
      {
          content: "";
        animation: animate 6s linear infinite;
         text-transform:uppercase;
        position: relative;
tansition:3s ease-in-out;
      }
    @keyframes animate {
        0%
        {
            content: 'this';
        }


        20%
        {
            content: 'is';
        }
        40%
        {
            content: 'a';
        }
        60%
        {
            content: 'cool';
        }
        80%
        {
            content: 'website';
        }
        95%
        {
            content: 'cspsyco';
        }

       100%
        {
            content: 'cspsyco';
        }
    }
    </style>
    <body>
        <br /><br /><br />
        <h1 align="center" class="h">
         
        </h1>
</body>
</html>

Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Introducing Cloudflare Pages ⚡