cm0002@lemmy.world to Programmer Humor@programming.dev · 3 days agoProgrammers then and nowimagemessage-square48fedilinkarrow-up1597
arrow-up1597imageProgrammers then and nowcm0002@lemmy.world to Programmer Humor@programming.dev · 3 days agomessage-square48fedilink
minus-squareObinice@lemmy.worldlinkfedilinkarrow-up23·3 days agoOkay but how do u center a div in 2025
minus-squareMadhuGururajan@programming.devlinkfedilinkEnglisharrow-up1·20 hours agouse display: flex flex-direction: column align-items: center on the parent container
minus-squareimpedans@lemmy.worldlinkfedilinkarrow-up7·edit-23 days 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.
minus-squareimpedans@lemmy.worldlinkfedilinkarrow-up3·3 days agoYeah that works if you wanna center a box of content it relative to the parent container, either horizontally or vertically. For other situations we’ve got different tools
minus-squareletsgo@lemm.eelinkfedilinkEnglisharrow-up3·2 days agoSame way you did it in 2024 but it’s easier because the springgirdles have been replaced with rotated manglebrackets.
minus-squareWhiskyTangoFoxtrot@lemmy.worldlinkfedilinkarrow-up2·edit-22 days agoMake your web page in GIMP, export to PNG, <img>.
minus-squarex00z@lemmy.worldlinkfedilinkEnglisharrow-up3·2 days agoAsk the browser nicely while using please and thanks.
minus-squarehakunawazo@lemmy.worldlinkfedilinkarrow-up1·2 days agoIt’s not about the center, it’s about the friends we made along the way.
minus-squareAnomalocaris@lemm.eelinkfedilinkarrow-up1·2 days agomaybe the div is already where it’s meant to be
minus-squareirelephant [he/him]@programming.devlinkfedilinkarrow-up1·2 days agoWhat threw me was having to set a width.
Okay but how do u center a div in 2025
use
display: flex
flex-direction: column
align-items: center
on the parent container
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
Yeah that works if you wanna center a box of content it relative to the parent container, either horizontally or vertically. For other situations we’ve got different tools
Same way you did it in 2024 but it’s easier because the springgirdles have been replaced with rotated manglebrackets.
Make your web page in GIMP, export to PNG,
<img>
.Ask the browser nicely while using please and thanks.
It’s not about the center, it’s about the friends we made along the way.
maybe the div is already where it’s meant to be
What threw me was having to set a width.