0

I have a text with two emojis
I want to flip one emogi with another using css.

When the first emogi is shown I want to the second emoji to be hidden. So they kinda indefinitely replacing each other.

I found here a great example how to make text blink

    .blink {
      animation: blinker 1s step-start infinite;
    }
    
    @keyframes blinker {
      50% {
        opacity: 0;
      }
    }
    
    <div class="blink"></div>

So how would you show the second emogi while the first one is hidden?

sreginogemoh
  • 9,074
  • 25
  • 83
  • 142

2 Answers2

2

.emoji-cont {
  position: relative;
}

.blink, .blink-2 {
    position: absolute;
}

.blink {
  animation: blinker 1s infinite;
}

.blink-2 {
  animation: blinker 1s .5s infinite;
}

@keyframes blinker {
  50% {
    opacity: 0;
  }
}
<div class="emoji-cont">
  <div class="blink"></div>
  <div class="blink-2"></div>
</div>
Sameer
  • 3,505
  • 3
  • 13
  • 33
1

You can use a pseudo-element:

.blink::before {
  content: "";
  animation: blinker 1s linear infinite alternate;
}

@keyframes blinker {
  0% {
    content: "";
  }
  50% {
    opacity: 0%;
  }
  100% {
    content: "";
  }
}
<div class="blink"></div>
iz_
  • 14,740
  • 2
  • 25
  • 40