cm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agoProgrammers then and nowlemmy.mlimagemessage-square22linkfedilinkarrow-up111arrow-down10cross-posted to: programmerhumor@lemmy.ml
arrow-up111arrow-down1imageProgrammers then and nowlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agomessage-square22linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareObinice@lemmy.worldlinkfedilinkarrow-up0·2 months agoOkay but how do u center a div in 2025
minus-squareRose@slrpnk.netlinkfedilinkarrow-up1·2 months agoIf using plain CSS, usually it’s enough to set width appropriately, and margin-left and margin-right to auto. If using a Modern Frontend/CSS Framework, then may God have mercy on your poor soul. (Seriously I just started a new project with TailwindCSS and I’m so confused. But not entirely desperate yet.)
minus-squareRicaz@lemmy.dbzer0.comlinkfedilinkEnglisharrow-up1·2 months agoI’m doing a small hobby project (a ladder/ranking system for playing beer sports with my community), and I tried out Tailwind. I gave up and loaded Bootstrap instead, but I will probably end up just writing all the CSS myself. Seems so silly to have 15 CSS classes on a single DOM element…
minus-squareɪᴍᴘᴇᴅᴀɴꜱ@lemmy.worldlinkfedilinkarrow-up0·edit-22 months agoIf you define what you mean by centering I’ll give you a straight answer. Vertically? Horizontally? Center the text or the entire box? Compared to the viewport, the parent container or the entire page? “Centering” isn’t as straight forward as you’d think, and what you actually want usually depends on the situation.
Okay but how do u center a div in 2025
If using plain CSS, usually it’s enough to set
width
appropriately, andmargin-left
andmargin-right
toauto
.If using a Modern Frontend/CSS Framework, then may God have mercy on your poor soul.
(Seriously I just started a new project with TailwindCSS and I’m so confused. But not entirely desperate yet.)
I’m doing a small hobby project (a ladder/ranking system for playing beer sports with my community), and I tried out Tailwind.
I gave up and loaded Bootstrap instead, but I will probably end up just writing all the CSS myself.
Seems so silly to have 15 CSS classes on a single DOM element…
If you define what you mean by centering I’ll give you a straight answer.
Vertically? Horizontally? Center the text or the entire box? Compared to the viewport, the parent container or the entire page?
“Centering” isn’t as straight forward as you’d think, and what you actually want usually depends on the situation.
Nah, just flex them boxes