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
-
@yendenikhil I've done this but no result with that one :/ (I do know the CSS basics)
-
Wack63116yI agree with @xewl, take a look at flexbox (or if IE support isn't an issue, even grid) css-tricks is a pretty good ressource for it: https://css-tricks.com/snippets/...
-
@linuxxx
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
- flexbox
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.
Related Rants
-
cdrice105"You gave us bad code! We ran it and now production is DOWN! Join this bridgeline now and help us fix this!" ...
-
MoboTheHobo35My Friend: Dude our Linux Server is not working anymore! Me: What? What did you do? My friend: Nothing I swe...
-
tommy15Right now someone at Google is coding something useless for us to laugh at on April Fools.
Spend quite a while at work trying to get two divs inside a centered div next to each other and especially get them the same height as the parent div.
Got it working after numerous tries, was going to take the code home to continue.
Forgot to take the code home, have to start over again and I hardly understand CSS 😥
Fuck me. (Writing a new service thingy by the way)
rant
fml