Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ltlian21966ySounds like google returned the exact answer to your question though!
Centering stuff in html/css can be anything from out of the box to deep magic hacks depending on what you need to do. -
Do you know what it means to center a div horizontally? To center a div vertically means the same thing, only vertically instead of horizontally.
-
Back in the days: margin: 0 auto;
These days: flex
If you feel fancy: absolute, top/left 50%, transform: translate(-50%, -50%) -
@C0D4 yeah well in table cells this is easy. But table cells in html are like unitialized memory in c. Of course you can use it but no don't
-
@nitwhiz i think the image was just to show what centering vertically means, and not a suggestion for a solution...
-
C0D4681386y@nitwhiz what better way to visualise centering of all available positions?
Also, for frontend web, you don’t have to use a table to do this, but the CSS will force your divs to behave like a table 🤷♂️ -
C0D4681386y@nothappy when in doubt, ask a fellow dev that has to deal with this magical mess on a daily basis 😏
-
h4xx3r17166y@nitwhiz 🤣 I went through all the stages. But now only grid and flex has meaning to me.
Related Rants
So for quite a time I've been trying to understand what does it mean to center a div 'vertically', I googled it but it returns only solutions to center it 'vertically', can anyone explain what does it mean to center it vertically?
question
legit