I want to use display:inline-block
per this SO Post here so that a div will take the dimensions of its children.
It works as stated in the post. The problem I'm having is that now my centering is broken by this change.
I was centering the div using
margin: 0px auto;
I want the div centered and I also want it to take the dimensions of it children.
Here is the CSS for the containing div:
#container-1{
display: inline-block;
position: relative;
top: 50px;
width: 1000px;
margin: 0px auto;
background: rgba(255, 255, 255, 0.5);
}
Here is the HTML - just two p tags in a div.
<div id="container-1">
<p id='si_but' class='si_match blue_but radius_all medium_white'>SignIn</p>
<p id='su_but' class='si_match orange_but radius_all medium_white'>SignUp</p>
</div>
and if needed the CSS for the 2 p tags:
.si_match{
cursor: pointer;
display: inline-block;
padding: 14px 14px;
text-decoration: none;
font-size: 14px;
}
#si_but{
position: relative;
left: 50px;
float: left;
}
#su_but{
position: relative;
right: 50px;
float: right;
}
Update: The larger concern is why is my containing div about 200 px to the left. There is nothing indicating why this is.