Vertically centering a number
I'm trying to center the numbers in these labels, but struggling to figure out how to deal with the little extra space on the bottom of the glyph (if that is the right term?). I'm guessing I'm over complicating this... any tips on how to get the number in the center of the circle?
I've tried putting flex on the label and tinkering around with "vertical-align" on both the label and its parent.
19 Replies
line-height: 1;
???ah, I did try
line-height: 1;
as well, forgot to mention that.I do have the actual radio input overlapping the same label at 0% opacity, not sure if that does anything weird, but changing that input to
display:none
didn't fix it either.mmmm I want to say there is a CSS property to make it more like monospaced
https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
but that would only handle the inline not the block? π€
honestly this is when I just reach for a 1px margin top (block-start) π
or some visual hacky solution
yea idk guess I can't find what I thinking of, swear there was something else besides for variant
line-height: 80% might work too xD (play with % value)
The issue you're having is that the line height also includes space for descenders (as is found in
g
, y
, q
, p
, etc). At present, I don't know of any CSS property that you can use to remove it. You could, however, use an image instead of a number and the image will be perfectly centered as images don't have decenders :p@doki3 I think I can help you. DO you have your project deployed somewhere for me to make some tests?
ah, not yet. let me push it to github
https://johncraven.github.io/fem-rating/
Sorry, the best solution I came up with was using padding-top .25em
remove line-height
Doesnt solve it π¦
no worries, thanks for checking it out. I might just close this for now
sideNote: Probably not a big deal but I notice you are styling the label, personally I would style the parent div. Then leave the label as just text. In my mental this is why I would have use margin-top vs padding
just more flexible approuch imo π€·ββοΈ
oh but it does not style the radio lol nvm sorry >.>;;
#depends CSS amr xD
bro why isnt that shit centering
i cant figure it out
wtf
bro βοΈ π
hmmm that makes sense
now i cant figure out why it is centering in tailwindπ π