If you include it to your site and add a ‘vertical-align’ class to any element it will align it vertically (and horizontally) to its parent element as long as the parent has (offset) height.
What would be the benefit of your JS solution compared to the one I use: I create a class ‘vertical-aligned’ in webflow, I set the parameters to top:50% and translate-x:-50%. Works pretty well too.
‘’ As a few people have pointed out, this method can cause elements to be blurry due to the element being placed on a “half pixel”. A solution for this is to set its parent element to preserve-3d. Like following: ‘’
One more reason to use JS instead of CSS3 can be found in the comments section of the above blog post.
‘‘This could have been the holy grail of vertical centering, but it seems to be causing text antialiasing issues during transitions, which is a big problem.’’
It’s very time consuming to fight against the blur, espcially text blur when you start to have many interactions/motion.
Everybody one the web has one solution that work for them and I end up with working code that I never fully understand and that ony does 99% of what I want (:
Last site I’m working on, I’m ending with this CSS custom code:
When antialias start to mess with things I usually notice it very fast… and so far never this CSS centering method did horrible things on my designs… I’ll be extra carreful now, and will give a try with your JS solution.
Maybe you’ll never have a problem. It’s just me that I like programming solutions, coming from a c++ background and been into the web industry since the ‘table’ era
Once a year I’m forced by a client (or: can’t refuse) to make a marketing email template and it’s like it’s all 1996 again and I cry and I want to die and I install Dreamweaver ‘just to see if it’s any better now’ (it’s not, it’s worse) then I want to make clay puppets out of some Adobe’s devs and there’s always a reason not to use Mailchimp. (Except this year I dropped $29 in an app specialized in marketing email templates. It’s just a table maker )
I can feel you man! That’s why my partner and designer (the illustrator ones) of the company now designs directly to webflow, so that I am here only to fix things…
[quote=“Diu, post:16, topic:9859”]
I’m lost. This function is SO awesome, that I want to use it for multiple elements. Isn’t there a way to not execute it for one element, but for more?
[/quote] You can use it for ONE element inside a container, but for many elements inside your page
The element with the vertical-align’ class has to be the only element inside its parent and the parent has to have width and height (either specified by absolute values or percentages).