I have the following code:
<div id="container">
<div id="div1">Div 1</div>
<div id="div2">Div 2</div>
</div>
I want to be able to have #box1 and #box2 one next to the other inside the container. Container is centered
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.
This will center the container, and have the two divs within it centered, while separating the styles from the actual content:
HTML:
CSS:
Working example:
http://jsfiddle.net/JLjjK/
2017 Update:
Flexbox is becoming much more commonplace. Here’s a way to achieve similar results with Flexbox:
HTML:
CSS:
Example: https://jsfiddle.net/pb61a1cj/1/