JSFiddle - React, Tailwind, and code Playground

by Neeraj Yadav

HTML

<div id="container">
  <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQcq4JZ5qtQK52zD4F7rEAHQRSU3_tiVNF6ww&usqp=CAU" alt="ship" class="ship" />
  
  <!-- <img class="lamp" src="https://cdn.iconscout.com/icon/premium/png-512-thumb/lamp-3122541-2621868.png" alt="lamp" /> -->
  
  <img class="glowing" src="https://cdn.iconscout.com/icon/premium/png-256-thumb/lamp-3122281-2621998.png" alt="lamp" />
  
  <img src="https://cdn.iconscout.com/icon/premium/png-256-thumb/lamp-3122021-2621738.png" class="color" />
</div>

CSS

#container {
  outline: green dashed 1px;
  width: 800px;
  height: 400px;
  position: relative;
}

.ship {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

/* .lamp {
  position: absolute;
  height: 120px;
  width: 120px;
  left: 35%;
  top: 15%;
  z-index: 2;
} */

.glowing {
  position: absolute;
  height: 120px;
  width: 120px;
  left: 35%;
  top: 15%;
  z-index: 2;
}

.color {
  position: absolute;
  height: 120px;
  width: 120px;
  left: 289px;
  top: 15%;
  z-index: 2;
}

@keyframes lampFadeInOut {
  0% {
    opacity: 1;
  }

  45% {
    opacity: 1;
  }

  55% {
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

#container img.color {
  animation-name: lampFadeInOut;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-duration: 5s;
  animation-direction: alternate;
}