Message Loader

by ChangJoo Park

HTML

<div class="wrapper">
  <div class="inner">
    <div class="messages">
      <div class="your-message message"></div>
      <div class="my-message message"></div>
    </div>
  </div>
</div>

CSS

.wrapper {
 margin: 0 auto;
 margin-top: 100px;
 width: 500px;
 height: 400px;
 background-color: tomato;
 position: relative;
 overflow: hidden;
}

.inner {
  width: 100%;
  height: 100%;
  background-color: #fff;
  position: relative;
  /* overflow: hidden; */
}

.inner::before {
  content: '';
  position: absolute;
  background-color: #D1DAE2;
  color: #fff;
  line-height: 40px;
  text-align: right;
  width: 100%;
  height: 40px;
  top: 0;
  left: 0;
}

.inner::after {
  content: '\00a0\263A';
  position: absolute;
  color: #fff;
  background-color: #ddd;
  width: 100%;
  height: 33px;
  line-height: 33px;
  bottom: 0;
  left: 0;
}

.inner .messages {
  padding-top: 40px;
  padding-bottom: 33px;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.message {
  width: 40%;
  height: 50px;
  position: absolute;
  bottom: 0;
  border-radius: 5px;
}
.my-message {
  background-color: #2786d5;
  position: absolute;
  right: 0;
  margin-right: 10px;
  animation-name: my-message-move;
  animation-duration: 3s;
  animation-timing-function: cubic-bezier(0,1,0,1);
  animation-fill-mode:forwards;
  animation-iteration-count: infinite;
  
}

.your-message {
  background-color: #efefef;
  left: 0;
  margin-left: 40px;
  animation-name: your-message-move;
  animation-duration: 3s;
  animation-timing-function: cubic-bezier(0,1,0,1);
  animation-fill-mode:forwards;
  animation-iteration-count: infinite;
}

.your-message::before {
  content: '';
  position: absolute;
  left: -40px;
  width: 35px;
  height: 35px;
  background-color: #efefef;
  border-radius: 100%;
  margin: 0;
}

@-webkit-keyframes your-message-move {
  0% {
    bottom: 0;
  }
  50% {
    bottom: 0;
  }
  100% {
    bottom: 120px;
  }
} 

@-webkit-keyframes my-message-move {
  0% {
    bottom: 0;
  }
  50% {
    bottom: 120px;
  }
  100% {
    bottom: 180px;
  }
}