使用css将表单居中

use*_*857 1 html css forms center

我正在尝试使用css的中心(到页面中间)一个html表单.

我已经读过其他成员的类似问题.但是,我无法弄清楚这一点

这是HTML表单:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="styles/form_style.css">
    <title>My Form</title>
</head>
<body>
    <form   action="#">
          <label for="name">Your Name:</label>
          <input type="text" name="name" id="name" /><br />

          <label for="email">Your Email:</label>
          <input type="text" name="email" id="email" /><br />

          <input type="checkbox" name="subscribe" id="subscribe" />
          <label for="subscribe" class="check">Subscribe</label>
    </form>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是CSS:

<style>
form{
  width: 700px ;
  margin-left: 0 auto;
}
label { 
    text-align:right; 
    width:100px; 
}
input { 
    margin-left: 10px; 
}
label.check, label.radio { 
    text-align:left; 
}
</style>
Run Code Online (Sandbox Code Playgroud)

我试了很久.但我仍然不能把形式集中在一起.任何指导?谢谢

Jos*_*ber 7

简写属性margin不是margin-left.修复它,它将集中在一起:

form {
  width: 700px ;
  margin: 0 auto;
}
Run Code Online (Sandbox Code Playgroud)

这是小提琴:http://jsfiddle.net/Tzr7D/