I have rows that are made of 2 sides: right side with text, and left side with buttons, separated by justify-content: space-between;
For the last row, I want to add a textarea, that would start from the right-most side of the buttons.
Is it possible to do it? In the snippet below you can see the textarea starts from the left side of the buttons. But I want it to start from the right most button, if possible.
I was not able to find a way since the amount of space the buttons take is dynamic, so where they end up in the right side is changing?
.container {
display: flex;
flex-direction: column;
}
.row {
display: flex;
justify-content: space-between;
}
.text {
align-self: center;
}
.buttons {
display: flex;
text-align: right;
}
.button {
border-radius: 10px;
padding: 10px;
margin-left: 10px;
height: 20px;
width: 50px;
}
.button.row_one {
background: purple;
border: 1px solid black;
}
.button.row_two {
background: red;
border: 1px solid black;
}
textarea {
resize: none;
border-radius: 10px;
padding: 10px;
margin-left: 10px;
height: 20px;
}
<div class="container" dir="rtl">
<div class="row">
<div class="text">
<p>Row 1</p>
</div>
<div class="buttons">
<div class="button row_one"></div>
<div class="button row_one"></div>
<div class="button row_one"></div>
<div class="button row_one"></div>
<div class="button row_one"></div>
</div>
</div>
<div class="row">
<div class="text">
<p>Row 2</p>
</div>
<div class="buttons">
<div class="button row_two"></div>
<div class="button row_two"></div>
<div class="button row_two"></div>
<div class="button row_two"></div>
<div class="button row_two"></div>
</div>
</div>
<div class="row">
<div class="text">
<p>Row 3</p>
</div>
<div class="textarea">
<textarea>Hello</textarea>
</div>
</div>
</div>
3
Answers
You can use
margin-right:0
in order to align to the rightI come up with a quite dirty solution which using
absolute
element oninvisible
element as shown below for 3rd row:You will want to use a two column layout with nested rows of consistent height.
Consider the following refactorization: