Search code examples
htmlcsshtml-tablealignmentvertical-alignment

How to align center text that next to a span?


I am trying to put "per month" vertical-align to the price "$29" just like the picture.You can help me fix my code or give me a new way that is better for me.

This is what I want.

enter image description here

This is what I had

enter image description here

here is my HTML code.

  <div class="deal">
          <span class="price">&dollar;29</span>
          <span class="period">per month</span>
        </div>

and my css.

.price {
  font-size: 50px;
}
.monthly {
  color: #d0d3d4;
  vertical-align: middle;
  display: inline-block;
}

Solution

  • CSS

    .deal{
      display:flex;
      align-items:center;
    }
    .period{
      margin-left:0.5rem;
    }
    

    jsfiddle