-1

My goal is simple, stick the p tag to the right side of the custom css card, to make it stick to the left it is pretty straightforward.

custom-text {
  margin-left: 30px;
}

To better illustrate thisenter image description here

The question is how do I make the $100 dollars always stick to the right? and let say the value of the dollars change to $5, how to make it always on the right?

I can just use

custom-text-right {
    margin-left: 450px;
}

but this solution doesn't scale to different value (Im using bootstrap just for your information)

HTML part:

<h4>Price: <span class="dollar">$3.15</span></h4>
sinusGob
  • 4,053
  • 12
  • 46
  • 82

2 Answers2

5

you can do that using flexbox, with justify-content: space-between;

.card {
  display: flex;
  height: 500px;
  width: 500px;
  background: #000;
  justify-content: space-between;
  color: white;
  padding: 30px;
  box-sizing: border-box
}
<div class="card">
  <span>Price:</span>
  <span> $100</span>
</div>
dippas
  • 58,591
  • 15
  • 114
  • 126
-1

You can use float: right or text-align:right

  • All else being equal, `float: right` would cause the price to drop down to the next line and `text-align: right` would either have no effect or align both bits of content to the right. It's possible to use both of these to get the desired effect, but not without additional work, so the answer isn't complete. – Quentin May 02 '17 at 10:58