Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text with different sizes on same line, how to align smaller text horizontally central with bigger text?

Tags:

html

css

enter image description here

As demonstrated in the above image (please take no notice of the fact the Dasboard text is abhorrently large - I only made it that size for this example), I want the text that says "Admin Control Panel" to be aligned horizontally middle with where the Dashboard text is, online with the red arrow.

The code I have for both these pieces of text are:

<div id="content-breadcrumb">
  Admin Control Panel &raquo;
    <span id="active">
      Dashboard
    </span>
</div>

The CSS code is:

#content-breadcrumb {
  font-family: 'Varela Round', sans-serif
  font-size: 16px;
}

#content-breadcrumb #active {
  font-size: 200px;
  color: #4F95C4;
}

Note that I have tried using vertical align and setting line height to no avail. Thanks for any help that you can offer!

like image 316
josef Avatar asked Feb 02 '26 08:02

josef


1 Answers

You can use flex box and align-items to accomplish this:

(PS: your closing div and span tags are missing the right caret)

#content-breadcrumb {
  display: flex;
  align-items: center;
  font-size: 1rem;
}
  
#active {
    font-size: 2rem;
}
  
<div id="content-breadcrumb">
  Admin Control Panel &raquo;
    <span id="active">
      Dashboard
    </span>
</div>
like image 142
Robert Wade Avatar answered Feb 03 '26 23:02

Robert Wade



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!