I want to add 2 button to the right of textarea,one on top and another under it using bootstrap and align them automatically,is it possible to achive with just using orignal bootstrap class?
with https://getbootstrap.com/docs/4.3/components/input-group/ showed example I can code some like :
<div class="input-group-prepend">
<span class="input-group-text">With textarea</span>
</div>
<textarea class="form-control" aria-label="With textarea"></textarea>
<div class="input-group-append" id="button-addon4">
<button class="btn btn-outline-secondary" type="button">Button</button>
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
</div>
which showed: But I want it like: and align them automatically (and maybe adjust their size by the size of textarea auto?) so is there a way could done it by just using orignal bootstrap class?
Use d-flex flex-column
on #button-addon4
div and also apply flex: 1 0 auto;
on the buttons to expand button's height when the textarea's height is increased.
.input-group-text,
.btn-outline-secondary {
flex: 1 0 auto;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container">
<div class="input-group-prepend">
<span class="input-group-text">With textarea</span>
</div>
<div class="d-flex">
<textarea class="form-control" aria-label="With textarea"></textarea>
<div class="d-flex flex-column" id="button-addon4">
<button class="btn btn-outline-secondary" type="button">Button</button>
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
</div>
<div class="input-group mt-4">
<textarea class="form-control" aria-label="With textarea"></textarea>
<div class="input-group-append d-flex flex-column">
<span class="input-group-text">Button 1</span>
<span class="input-group-text">Button 2</span>
</div>
</div>
</div>