0

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

Firefox 中的布局

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

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;
}

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

4

1 回答 1

1
<div align="center">

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

于 2012-12-15T20:27:24.327 回答