Skip to content

pro tip to center any absolute div within a relative div #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

ktkaushik
Copy link

Let me know if this is okay please. I have created a small codepen for demonstration as well.

@AllThingsSmitty
Copy link
Owner

@ktkaushik thanks for the suggestion. I'm not certain what the use case is for this kind of tip. It seems more like an edge case on not something that devs would get much value from using regularly.

@wmertens
Copy link

It is the best way to center a div if you know its size and you don't have flexbox available. It doesn't work if the centered div is not a fixed size.

@vikrantnegi
Copy link

Yes CSS-tricks have all the centering techniques you need to know.

@AllThingsSmitty
Copy link
Owner

Given that the CSS-Tricks post has a lot of good suggestions I've simply added a link to it under the tip for vertically-centering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants