【问题标题】:Dynamic Selectbox not centering correctly in IE7动态选择框在 IE7 中未正确居中
【发布时间】:2010-07-15 16:09:38
【问题描述】:

我有一个用 Ajax 调用动态填充的选择框。用户在文本框中输入邮政编码,然后选择框会填充该邮政编码中的城市。我的问题是选择框开始为空但正确居中。一旦它从 Ajax 响应中动态填充,IE 就会将选择框向右扩展,并且不会根据新宽度重新定位它。 Firefox 和 Chrome 运行良好。我正在使用IE7进行测试。这是代码...

    <table width="400" cellspacing="0" cellpadding="2" border="0">
 <tr>
  <td align="center" colspan="2" class="greyheader">Location
  Information</td>
 </tr>
 <tr>
  <td colspan="2" align="center" class="grey"><span class="pagetitle1">&gt;&nbsp;</span>Please
  use only United States, Puerto Rico or Canada zip codes</td>
 </tr>
 <tr bgcolor="#E1E1E1">
  <td width="200" align="center"><b><u>Origin Zip Code</u></b></td>
  <td width="200" align="center"><b><u>Destination Zip Code</u></b></td>
 </tr>
 <tr bgcolor="#E1E1E1">
  <td width="200" align="center">
   <div id="czipS" class="shipperSpecific">
       &nbsp; 
   </div>
   <div class="consigneeSpecific">
   <center>
   <input size="7" type="text" autocomplete="off" maxlength="7"
    name="originZip" id="originZip" onkeypress="return handleEnter(this,event);"/>
   </center>
   </div>
  </td>
  <td  width="200" align="center">
   <div id="czipC" class="consigneeSpecific">
    &nbsp;
   </div>
   <div class="shipperSpecific">
   <center>
   <input size="7" type="text" autocomplete="off" maxlength="7"
    name="destZip" id="destZip" onkeypress="return handleEnter(this,event);" /> 
   </center>
   </div>
  </td>
 </tr>
 <tr bgcolor="#E1E1E1"> 
  <td  width="200" align="center">
   <div class="consigneeSpecific">
   <select id="originCity" name="originCity" />
   </div>
  </td> 
  <td  width="200" align="center">
   <div class="shipperSpecific">
   <select name="destCity" id="destCity" />
   </div>
  </td>
 </tr>
</table>

【问题讨论】:

    标签: javascript html css internet-explorer-7


    【解决方案1】:

    如果我看过 ajax 代码和插入,我会提供更好的帮助。

    尝试在插入完成后将居中对齐类重新设置为选择框。通常,这会触发 IE 重新计算。

    类似这样的东西(jquery):

    $('#destCity').removeClass('alignCenter').addClass('alignCenter');
    

    【讨论】:

    • 谢谢。我做了类似的事情,但使用原型而不是 jquery。
    猜你喜欢
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 2019-08-28
    • 1970-01-01
    • 2011-06-21
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多