TD宽度超过指定

时间:2013-10-11 00:17:52

标签: html asp.net css web

我有一张表格如下

    <table style="border-spacing: 10px; width:auto; table-layout: fixed" id="tblCustomerinput">
       <tbody>
            <tr>
                <td width="2px">
                   <span class="error"> *</span>
                 </td>
                 <td style="width: auto;resize: horizontal;">
                    <span>Required Field</span>
                 </td>
                 <td>
                     <span id="cvEventsValidator" class="error" style="display:none;">Please complete the required fields below.</span>
                      <span id="reqFieldValidator" class="error" style="color:Red;display:none;">Please complete the required fields below.</span>
<br>

                </td>
             </tr>
             <tr>
                <td width="2px">

                </td>
                <td width="130px">
                  <b> <span id="lblCustNumber">Customer Number:</span></b>  
                 </td>
                 <td>
                    <input name="txtCustNumber" type="text" maxlength="50" id="txtCustNumber"> 
                 </td>
                </tr>
                <tr>
                   <td width="2px"><span class="error">*</span>
                   </td>
                   <td width="130px">
                      <b> <span id="lblFirstName">First Name:</span>  </b>
                   </td>
                   <td>
                       <input name="txtFirstName" type="text" maxlength="50" id="txtFirstName" class="requiredfield">
                   </td>
                 </tr>
                 <tr>
                    <td width="2px"><span class="error">*</span>
                    </td>
                    <td width="130px">
                                        <b> <span id="lblLastName">Last Name:</span></b>
                    </td>
                    <td>
                        <input name="txtLastName" type="text" maxlength="50" id="txtLastName" class="requiredfield">
                    </td>
                  </tr>
                  <tr>
                    <td width="2px">

                    </td>
                  <td width="130px">
                    <b> <span id="lblCompanyName">Company Name:</span></b>
                  </td>
                  <td>
                     <input name="txtCompanyName" type="text" maxlength="50" id="txtCompanyName">
                  </td>
                </tr>
                <tr>
                   <td width="2px" span="" class="error">*
                   </td>
                   <td width="130px">
                                       <b>  <span id="lblPhoneNumber">Phone Number:</span></b>
                    </td>
                    <td>
                       <input name="txtPhoneNumber" type="text" maxlength="50" id="txtPhoneNumber" class="requiredfield">
                    </td>
                   </tr>
                   <tr>
                      <td width="2px"><span class="error">*</span>
                      </td>
                      <td width="130px"><b>
                         <span id="lblEmail">E-mail Address:</span></b>
                      </td>
                      <td>
                           <input name="txtEmail" type="text" maxlength="50" id="txtEmail" class="requiredfield">
                      </td>
                     </tr>
                     <tr>
                      <td width="2px">

                      </td>
                      <td width="130px">
                          <b> <span id="lblDynamicField" maxlength="50"></span></b>
                      </td>
                      <td>
                          <input name="txtDynamicField" type="text" maxlength="50" id="txtDynamicField">
                      </td>
                    </tr>                                              
                    <tr>
                       <td colspan="2"><span id="Label1">Comments:</span> &nbsp;
                                     <br>

                          <textarea name="txtComment" rows="5" cols="20" id="txtComment" class="feedback_comment" onkeypress="return this.value.length &lt;=1500" onkeydown="limitText(this,1500);" onkeyup="limitText(this,1500);" style="width:360px;" clicks="0" onfocus="clearContents(this);">Please describe the problem you found...</textarea></td>
                     </tr>
                 </tbody>
         </table>

第二个的宽度总是出现为347px,原因我无法理解(!! ??) 我将td的固定宽度设置为130像素。 有人可以帮我这个吗?我一直在挠头直到它为此疼痛:) 基本上我需要将标签排列在靠近文本框的位置。

一如既往地感谢您的帮助。

由于

1 个答案:

答案 0 :(得分:3)

跨越第一列和第二列的textarea的默认宽度大于130px。您需要将textarea的宽度设置为130px或更小。或者您可以将textarea的父级td colspan跨越3列而不是2列。