<button type="button" onclick="snackBarFunc()">Show</button>
  <p id="snackbar">Nice to meet you</p>

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button {
  width: 300px;
  height: 50px;

  background-color: #000;
  border: none;

  color: #fff;
  font-size: 20px;
}


#snackbar {
  visibility: hidden;
  position: absolute;
  width: 300px;

  background-color: #fff;
  border: solid 1px #000;

  padding: 20px;

  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);

  border-radius: 5px;

  color: #000;
  font-size: 18px;
  text-align: center;
}


#snackbar.show {
  visibility: visible;
  animation:  fadeIn 0.5s, fadeOut 0.5s 2.5s forwards; 
}

@keyframes fadeIn {
  from {
    bottom: 0;
    opacity: 0;
  }

  to {
    bottom: 30px;
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    bottom: 30px;
    opacity: 1;
  }

  to {
    bottom: 0;
    opacity: 0;
  }
}


function snackBarFunc() {
  var snackbar = document.querySelector("#snackbar");
  snackbar.classList.add('show');

  setTimeout(function() {
    snackbar.classList.remove('show');
  }, 3500); 
  // fadein 0.5초 + fadeout 3초가 끝남과 동시에 진행되게 하기 위해
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.