how to center this? n00b question
Hi, I am a newbie to this, honestly,
and i've come across this issue in css, seen in the image, where the icon isn't properly aligned with the text. How can I bring the icon font down to the center and raise the text font up?

11 Replies
Can you put this in a codepen please? 😄
https://codepen.io/
sure, I just did now. https://codepen.io/Yoo-the-styleful/pen/raORQgG
Ah, you have
display: inline on your .sidenav-item-container. Changing that to display: flex combined with what you already have (align-items: center) will center it verticallyThis is the devtools view (f12 on your keyboard)

I am new to this, what if I don't want to make it a flex box, and just keep it as a regular div?
Why wouldn't you want to use flex?
So, since I am new, I like to try out different things. I don't really see a need for a flex here because I just want a div container
I prefer a div over a flex when the design doesn't require the div to shrink/grow or wrap.
I think your thought process is good: too many beginners throw flex on everything when it isn't needed. But what you want to do here is center items, and to do that it's easiest to use flex or grid.
Div vs. flex: Div is an html element and flex is a css value. I'm assuming you mean
display: inline or block? display: inline is inline-level elements, like spans. Divs are display: block by default, and you're changing it to inline.
I could get into it but it would probably take me a long time to write this all out... basically what you're doing is making both the icon and the label inline, but they're different font families and font sizes. You can try to make these the same font size, line height, etc. and see if that will visually center it vertically... or you can just throw a display: flex; align-items: center and be done with itI ment
inline-block, I made a mistake there.I removed all the styles on the material symbols class just to showcase that making them
inline or inline-block works now; they're aligned vertically. But the font family of the material icon makes centering it tricky
oh, I see.