I have div with no fixed with. I want this div position in the center of screen.
I know how to make this with jquery, but with pure css, I did not find any solution. How do you make this happen with pure css?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you want to shrink-wrap the contents of the div (otherwise centring it is a pointless exercise as its width will be the width of the container):
display: inline-block;on the div to make it shrink-wraptext-align: center;on the div’s parent element to centre the divtext-align: left;on the div to override the centring of its inline content that it would inherit from its parent.