3

I am trying to have left and right alignment in my HTML. It works fine when the fonts are the same size, but they do not align when the fonts are different sizes.

.right {
  float: right;
  display: inline
}

.left {
  float: left;
  font-size: 300%;
  display: inline
}
<span class="left">Left Alignment</span>
<span class="right"> Right Alignment</span>

I would like the two spans to be aligned by the bottom of the text. Can somebody please help me with this?

Thanks!

0

2 Answers 2

2

You can use flex-box with the align-items:baseline; property

div{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px;
}

.left{
    font-size: 300%;
}
<div>
<span class="left">Left Alignment</span>
<span class="right"> Right Alignment</span>
</div>

Sign up to request clarification or add additional context in comments.

Comments

0

Flexbox can do that...but it requires a wrapper element.

.left {
  font-size: 300%;
}

div {
  width: 90%;
  margin: 1em auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 2px solid grey;
}
<div>
  <span class="left">Left Alignment</span>
  <span class="right"> Right Alignment</span>
</div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.