CSS / HTML表单:IE和Opera中的按钮对齐错误

时间:2012-12-15 17:33:42

标签: html css forms cross-browser

我目前在HTML表单中遇到了一个奇怪的对齐问题。 在Firefox / Chrome / Konqueror中,布局很好 - 见下文

Layout in FireFox

但是在IE8和Opera中,布局看起来像这样:

Layout in IE

我的HTML看起来像这样

<body bgcolor="#FFFFFF" text="#3d4144" id="jobs">
<div align="center">
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>          
    <td style="text-align: center;">Please login to post a job.</td>
      </tr>
      <tr>
    <td>
   <div id="stylized" class="myform">
     <form id="form" name="form" method="post" action="loginproc.php">
      <label>Username:
      <span class="small">Enter your e-mail</span>
      </label>
      <input type="text" name="name" id="name">
      <label>Password:
      <span class="small">Enter your password</span>
      </label>
      <input type="password" name="password" id="password">
      <button type="submit">Login</button>       
     </form>                 
  </div>​
</td>
  </tr>
  <tr>
<td style="text-align: center;">
  <a class="body" href="register.php" style="text-decoration: none">If you are not registred yet, you can signup here (free of charge)!</a>
</td>
  </tr>
  </table>

 我的CSS看起来像这样

#stylized input{
float:left;
font-size:10px;
font: normal Verdana,sans-serif;
padding:5px 2px;
border:solid 1px #2B578A;
width:200px;
margin:2px 0 10px 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}

#stylized input[type="password"]{
float:left;
font-size:10px;
font: normal Verdana,sans-serif;
padding:5px 2px;
border:solid 1px #2B578A;
width:200px;
margin:2px 0 10px 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}


#stylized label {
display:block;
font-weight:bold;
float: left;
width: 10em;
margin-right: 1em;
text-align: right;
width:140px;
}

#stylized .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}

.myform{
margin:0 auto;
width:400px;
padding:14px;
}

#stylized button{
clear:both;
margin-left:160px;
width:120px;
height:25px;
text-align:center;
line-height:20px;
color:#FFFFFF;
font-size:11px;
font-weight:bold;
background:#414549;
font-family: Verdana, sans-serif;
border: 0px solid #2B578A;
}

#stylized button:hover{
background:#2B578A;
color:#FFFFFF;
border: 0px solid #2B578A;
}

一旦我将表单放入表格(我出于某些设计目的),问题就开始了。

1 个答案:

答案 0 :(得分:1)

<div align="center">

那是罪魁祸首。删除它或在提交按钮周围的元素上设置“text-align:left”。