Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
yendenikhil235515dSet to inner div
This should work
Also; TailwindCSS ftw
Kaji201315dCentering sucks in CSS. Especially vertical centering.
1. Is the height defined in the parent (centered) div or one of the inner divs?
2. Does the height of all have to expand by the content of the inner divs? (no overflow/hiding)
3. Is the parent centered horizontally and/or vertically?
There are multiple possibilities depending on your requirements, even without the use of flexbox.
@Kaji It's not that difficult. The problem is rather that it's often either tought badly or not correctly explained.
There are multiple ways of v-centering stuff:
- inline/line-height approach
- absolute pos/translate approach
- relative pos/translate/neg. margin approach
- table-cell approach
Which you chose depends on other factors such as:
- whether the outer container should grow in height if v-center content is vertically too big
- whether the outer countainer has a defined height
- what kind of other styles have to be applied the the v-center container
- browser compat.
DavinaLeong58115dGrid and Flexbox FTW
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job
cdrice74"You gave us bad code! We ran it and now production is DOWN! Join this bridgeline now and help us fix this!" ...
MoboTheHobo27My Friend: Dude our Linux Server is not working anymore! Me: What? What did you do? My friend: Nothing I swe...
tommy10Right now someone at Google is coding something useless for us to laugh at on April Fools.