0

I am making a messaging app so it's just like whatsapp. I am making a parent div which contains messages. The child div contains the text field and send button. I want to position the child div such that when you scroll through messages the text field and the button remain at the bottom of the parent container.I have already used bootstrap 4's fixed bottom. But It doesn't work...

I have also seen other stack flow answers which say: To put position: relative; in the parent and position: absolute in the child div. But this also doesn't work.

This is my parent container..

<div class="container justify-content-center w-50 position-relative" style="height: 400px; overflow-y: auto; ">
<app-message-container></app-message-container>
</div>

This is my child container i.e app-message-container..

<div class="container d-flex fixed-bottom position-absolute">
<input class="form-control" type="text" placeholder="Enter Text">
<button class="btn btn-success">Send</button>
</div>
<p>Alias inventore doloremque inceptos soluta, aliqua quaerat totam 
sccusantium quibusdam dolor vestibulum. Class? Non sapiente exercitation 
libero quaerat hic sociis voluptas laboris! Interdum nemo mattis posuere 
fermentum mus auctor iaculis adipisci? Blandit.</p>

Thanks in advance

2 Answers2

0

You would want to remove position-absolute and position-relative class if you already use fixed-bottom (is position: fixed which is correct in your case).

<div class="container d-flex fixed-bottom">

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container justify-content-center w-50" style="height: 400px; overflow-y: auto; ">  
  <div class="container d-flex fixed-bottom">
     <input class="form-control" type="text" placeholder="Enter Text">
     <button class="btn btn-success">Send</button>
  </div>
  <p>Alias inventore doloremque inceptos soluta, aliqua quaerat totam 
  sccusantium quibusdam dolor vestibulum. Class? Non sapiente exercitation 
  libero quaerat hic sociis voluptas laboris! Interdum nemo mattis posuere 
  fermentum mus auctor iaculis adipisci? Blandit.</p>
</div>
Victoria Le
  • 860
  • 6
  • 15