Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

How to center align a form in the middle of div?

Ads
banner
banner
banner
zorro Offline referral

Posts: 127
Joined: Mar 2014
Reputation: 0

#1
Member
I have a form in my HTML code but it's aligned to the right. It's wrapped with div so I would like to position the form in the middle of div how to do it?
surenot Offline referral

Posts: 500
Joined: Jan 2014
Reputation: 16

#2
Senior Member
Use CSS margin: auto; property. First give the div a width:

HTML
Code:
<div class="wrapper">
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
</div>

CSS
Code:
.wrapper {
    width: 600px;
}

Now lets give form width and add margin.

CSS
Code:
.wrapper form {
    margin: 0 auto;
    width: 220px;
}





User(s) browsing this thread: 1 Guest(s)