I'm trying to create a mini-register bar on the left side of the site, and on the middle to create some data page.
So I used float:left
for the mini-register bar and text-align:center
for the body.
I read this Align a div to center and now tried instead of text-align
property, use margin: 0 auto
for whole div.
But now the body sticks to the left mini-register bar and isn't placed on the center.
Mini register bar
<div id="LoginOrRegister">
<form action="#" method="post" style="margin-top:30px;">
Username: <input id="text" type="text" required="required">
Password: <input type="password" required="required"></br>
<input type="submit" value="Sign In"> <strong>Or</strong> <a href="#"><button>Register</button></a>
</form>
</div>
Body data
<div style="margin: 0 auto;">
<p>
<h1><u>some data</u></h1>
</p>
</div>
CSS
#LoginOrRegister {
float:left;
border: 4px solid #0279ec;
padding:5px;
width: 260px;
height:140px;
}
button, input {
cursor:pointer;
}
A demo
http://jsbin.com/yofeluna/1
Thanks