How to make div inside a absolute parent stick to bottom?

I believe it’s really straightforward, using a position: fixed and bottom: 0. See the below snippet in its full screen:

.chat {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 160px;
  height: 20px;
  background-color: #000;
  border-radius: 15px 0 0 0;
  transition: all 0.5s linear;
  cursor: pointer;
  color: #fff;
  padding: 15px;
  border: 2px solid #000;
}

.chat span {
  color: #000;
  background-color: #fff;
  display: block;
  padding: 3px;
  border-radius: 3px;
  border: 1px solid #000;
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
}

.chat.open {
  height: 350px;
  width: 250px;
  color: #000;
  background-color: #fff;
}
<div class="chat" onclick="this.classList.toggle('open');">
  <span>Click Me!</span>
</div>

Preview

demo

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top