Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep items on same vertical

Tags:

html

css

I want to make currency icons on the same vertical line.

What I want:

enter image description here

What do I have now:

enter image description here

.column {
  display: flex;
  flex-direction: column;
  padding: 10px 10px 10px 0;
}

.cell {
  text-align: right;
}
<div class="column">
  <div class="cell">
    <div class="item">
      <span>123123 $</span>
    </div>
    <div class="item">
      <span>(123 $)</span>
    </div>
    <div class="items">
      <span>(1235 $)</span>
    </div>
    <div class="item">
      <span>12414 $</span>
    </div>
  </div>
</div>
like image 728
halcyon Avatar asked Jul 10 '26 12:07

halcyon


1 Answers

Just generate the () using ::before and ::after with a CSS class for the task, and use CSS grid to arrange them:

.column {
  display: grid;
  grid-template-columns: max-content;
  padding: 10px 10px 10px 0;
  justify-items: end;
}

.cell {
  text-align: right;
}

.brackets {
  position: relative;
}

.brackets span::before,
.brackets span::after {
  position: absolute;
}

.brackets span::before {
  content: "(";
  left: -.35em;
}

.brackets span::after {
  content: ")";
  right: -.35em;
}
<div class="column">
  <div class="item">
    <span>123123 $</span>
  </div>
  <div class="item brackets">
    <span>123 $</span>
  </div>
  <div class="items brackets">
    <span>1235 $</span>
  </div>
  <div class="item">
    <span>12414 $</span>
  </div>
</div>
like image 135
connexo Avatar answered Jul 12 '26 00:07

connexo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!