Designer News
Where the design community meets.
8 years ago from John Emerson, backspace.com
Quite a few people are upvoting this, but please don't do this. :( You break transitions, and transforms like this are subject to subpixel positioning, causing text and other elements to end up blurry sometimes.
All of these techniques have drawbacks and each are useful in different scenarios. You just have to decide which drawbacks are worth it for what you're trying to do.
Designer News
Where the design community meets.
Designer News is a large, global community of people working or interested in design and technology.
Have feedback?
Using
transform: translateX(-50%) translateY(-50%); top: 50%; left: 50%; position: absolute;
is a lot nicer for elements with unknown width/height.Edit: Forgot the negative signs.