日期:2014-05-17  浏览次数:20618 次

求教一段简单的table样式,为啥chrome,ie下有问题(opera,ff下正常))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <style type="text/css">
  .borderStyle
  {
  border-style:solid;
  border-color:Black;
  border-width:1px;
  width:250px;
  height:132px;
  }
  .td1
  {
  width:70px;
  }
  .td2
  {
  width:150px;
  }
  .rightstyle
  {
  float:right;
  }
   
  </style>

</head>
<body>

<div id="loading" class="borderStyle" >
<table >
<tr><td class="td1"><label for="username">用户名</label></td><td class="td2"><input id="username" type="text" /></td></tr>
<tr><td class="td1"><label for="pwd">密码</label></td><td class="td2"><input id="pwd" type="password" /></td></tr>
<tr><td class="td1"></td><td class="td2"><input class="rightstyle" type="button" value="取消" /><input class="rightstyle" type="button" value="确定"</td></tr>
</table>
</div>

</body>
</html>


------解决方案--------------------
各个浏览器对html各标签有各自的解析方式。

正如楼主所述的在ie下,两个input的长度不一样,如果楼主把password换成text,两个input的长度就一致了

xhtml css 来布局,想达到在各个浏览器的预想效果,一般要重置下css,即reset css,比如楼主説两个input长度不一样,可以在css中定义它们的width,来达到一致的效果