cm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agoProgrammers then and nowimagemessage-square49fedilinkarrow-up1605
arrow-up1605imageProgrammers then and nowcm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agomessage-square49fedilink
minus-squareObinice@lemmy.worldlinkfedilinkarrow-up23·2 months agoOkay but how do u center a div in 2025
minus-squareimpedans@lemmy.worldlinkfedilinkarrow-up7·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.
minus-squareimpedans@lemmy.worldlinkfedilinkarrow-up3·2 months 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-squarex00z@lemmy.worldlinkfedilinkEnglisharrow-up3·2 months agoAsk the browser nicely while using please and thanks.
minus-squareletsgo@lemm.eelinkfedilinkEnglisharrow-up3·2 months 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 months agoMake your web page in GIMP, export to PNG, <img>.
minus-squarehakunawazo@lemmy.worldlinkfedilinkarrow-up1·2 months agoIt’s not about the center, it’s about the friends we made along the way.
minus-squareMadhuGururajan@programming.devlinkfedilinkEnglisharrow-up1·2 months agouse display: flex flex-direction: column align-items: center on the parent container
minus-squareirelephant [he/him]@programming.devlinkfedilinkarrow-up1·2 months agoWhat threw me was having to set a width.
minus-squareAnomalocaris@lemm.eelinkfedilinkarrow-up1·2 months agomaybe the div is already where it’s meant to be
Okay but how do u center a div in 2025
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
Ask the browser nicely while using please and thanks.
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>
.It’s not about the center, it’s about the friends we made along the way.
use
display: flex
flex-direction: column
align-items: center
on the parent container
What threw me was having to set a width.
maybe the div is already where it’s meant to be