如何以适当的方式获取表标记的td标记

时间:2016-03-04 11:55:05

标签: javascript jquery html css jsp

我正在使用<table><tr><td>标签来设计一个表。我设计了一个表但是当来自数据库的数据进行设计时会发生什么表扩展看起来很糟糕。我将显示一个图像。enter image description here

正如您在上面的图片中看到的那样,当数据扩展时,表格宽度也在扩展,但我需要的是扩展<td>标签的高度而不是宽度。我发布的代码如下我做了。

<div style="border-left: 1px solid black;border-right: 1px solid black;border-top: 1px solid black;width:608px"><center><span style="font-size: 18px;"><b>Tax Invoice cum Delivery Challan &nbsp&nbsp&nbspBuyer/Seller Copy</b></span></center></div>
            <table align="center" style="border: 1px solid " cellpadding="0" cellspacing="0" width="100%">
               <tr>
               <td rowspan="3" style="border-right: 1px solid black; width: 300px">
               &nbsp<%= companyName%><br/>
                        &nbsp<%= branchLocationAddress%><br/>
                        <b>&nbspMobile Number: </b><%= mobileNumber%><br/>
                        <b>&nbspPhone Number: </b><%= landLineNumber%><br/>
                        <b>&nbspEmail ID: </b><%= emailID%>
               </td>
               <td style="border-right: 1px solid black;border-bottom: 1px solid black;"><b>&nbspInvoice No</b><br/>
                   &nbsp<%= invoiceno%></td>
               <td style="border-bottom: 1px solid black;"><b>&nbspInvoice Date</b><br/>
                        &nbsp<%= invoicedate%></td>
               </tr>
               <tr>

               <td style="border-right: 1px solid black;"><b>&nbspDelivery Note</b><br/>
                   &nbsp<%= deliverynote%></td>
               <td><b>&nbspMode Of Payment</b><br/>
                    &nbsp<%= termsofpayment%> </td>    
               </tr>
               <tr>

               <td style="border-top: 1px solid black;border-bottom: 1px solid black;border-right: 1px solid black;"><b>&nbspESugam No</b><br/>
                   &nbsp<%= esugamno%></td>
               <td style="border-top: 1px solid black;border-bottom: 1px solid black;"><b>&nbspOther Reference</b></td> 
               </tr>
               <tr>
               <td rowspan="3" style="border-top: 1px solid black; width: 300px;border-right: 1px solid black;"><b>&nbspOrganizationName: </b><%= orgname%><br/>
                        <b>&nbspDelivery Address: </b><%= deliveryaddress%><br/>
                        <b>&nbspPhone No :</b><%= phone%></td>
                <td style="border-right: 1px solid black;border-bottom: 1px solid black"><b>&nbspBuyer Order No</b><br/>
                        &nbsp<%= buyerorderno%></td>  
                <td style="border-bottom: 1px solid black;"><b>&nbspBuy Date</b><br/>
                         &nbsp<%= buydate%></td>              
               </tr>
               <tr>

               <td style="border-right: 1px solid black;border-bottom: 1px solid black;"><b>&nbspDispatch Document No</b><br/> 
                        &nbsp<%= dispatchdocumentno%></td>
               <td style="border-bottom: 1px solid black;"><b>&nbspDated</b><br/>
                      &nbsp<%= dated%></td>         
               </tr>
               <tr>

               <td style="border-right: 1px solid black;"><b>&nbspDispatch Through</b><br/>
                          &nbsp<%= dispatchthrough%></td>
               <td><b>&nbspDestination</b><br/>
                        &nbsp<%= destination%></td>           
               </tr>
                </table> 
            <table align="center" style="border-bottom: 1px solid " cellpadding="0" cellspacing="0" width="100%">

               <tr>
               <td rowspan="1" style="width:300px; border-left: 1px solid black; border-right: 1px solid black;"><b>&nbspWorks Address: Same As Above</b></td>
               <td style="border-right: 1px solid black;"><b>&nbspTerms Of Delivery :- </b><%= termsofdelivery%><br/>
                      <b>&nbspAttention :- </b><%= attention %></td></tr>
                  </table>  

3 个答案:

答案 0 :(得分:0)

word-break: break-all 

诀窍

答案 1 :(得分:-1)

你的div在桌子开始前关闭。将你的桌子包裹在div中。

mysql> SELECT max( dateTime ) FROM archive;
+-----------------+
| max( dateTime ) |
+-----------------+
|      1457104500 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT max( FROM_UNIXTIME(dateTime,"%M %m") ) as 'date' FROM archive;
+----------+
| date     |
+----------+
| March 03 |
+----------+
1 row in set (0.02 sec)

mysql> SELECT max( FROM_UNIXTIME(dateTime,"%m %M") ) as 'date' FROM archive;
+-------------+
| date        |
+-------------+
| 12 December |
+-------------+
1 row in set (0.02 sec)

干杯

答案 2 :(得分:-1)

您的div标签在表标记之前被关闭。这样做: -

    <div style="border-left: 1px solid black;border-right: 1px solid black;border-top: 1px solid black;width:608px"><center><span style="font-size: 18px;"><b>Tax Invoice cum Delivery Challan &nbsp&nbsp&nbspBuyer/Seller Copy</b></span></center>
        <table align="center" style="border: 1px solid " cellpadding="0" cellspacing="0" width="100%">
           <tr>
           <td rowspan="3" style="border-right: 1px solid black; width: 300px">
           &nbsp<%= companyName%><br/>
                    &nbsp<%= branchLocationAddress%><br/>
                    <b>&nbspMobile Number: </b><%= mobileNumber%><br/>
                    <b>&nbspPhone Number: </b><%= landLineNumber%><br/>
                    <b>&nbspEmail ID: </b><%= emailID%>
           </td>
           <td style="border-right: 1px solid black;border-bottom: 1px solid black;"><b>&nbspInvoice No</b><br/>
               &nbsp<%= invoiceno%></td>
           <td style="border-bottom: 1px solid black;"><b>&nbspInvoice Date</b><br/>
                    &nbsp<%= invoicedate%></td>
           </tr>
           <tr>

           <td style="border-right: 1px solid black;"><b>&nbspDelivery Note</b><br/>
               &nbsp<%= deliverynote%></td>
           <td><b>&nbspMode Of Payment</b><br/>
                &nbsp<%= termsofpayment%> </td>    
           </tr>
           <tr>

           <td style="border-top: 1px solid black;border-bottom: 1px solid black;border-right: 1px solid black;"><b>&nbspESugam No</b><br/>
               &nbsp<%= esugamno%></td>
           <td style="border-top: 1px solid black;border-bottom: 1px solid black;"><b>&nbspOther Reference</b></td> 
           </tr>
           <tr>
           <td rowspan="3" style="border-top: 1px solid black; width: 300px;border-right: 1px solid black;"><b>&nbspOrganizationName: </b><%= orgname%><br/>
                    <b>&nbspDelivery Address: </b><%= deliveryaddress%><br/>
                    <b>&nbspPhone No :</b><%= phone%></td>
            <td style="border-right: 1px solid black;border-bottom: 1px solid black"><b>&nbspBuyer Order No</b><br/>
                    &nbsp<%= buyerorderno%></td>  
            <td style="border-bottom: 1px solid black;"><b>&nbspBuy Date</b><br/>
                     &nbsp<%= buydate%></td>              
           </tr>
           <tr>

           <td style="border-right: 1px solid black;border-bottom: 1px solid black;"><b>&nbspDispatch Document No</b><br/> 
                    &nbsp<%= dispatchdocumentno%></td>
           <td style="border-bottom: 1px solid black;"><b>&nbspDated</b><br/>
                  &nbsp<%= dated%></td>         
           </tr>
           <tr>

           <td style="border-right: 1px solid black;"><b>&nbspDispatch Through</b><br/>
                      &nbsp<%= dispatchthrough%></td>
           <td><b>&nbspDestination</b><br/>
                    &nbsp<%= destination%></td>           
           </tr>
            </table> 
        <table align="center" style="border-bottom: 1px solid " cellpadding="0" cellspacing="0" width="100%">

           <tr>
           <td rowspan="1" style="width:300px; border-left: 1px solid black; border-right: 1px solid black;"><b>&nbspWorks Address: Same As Above</b></td>
           <td style="border-right: 1px solid black;"><b>&nbspTerms Of Delivery :- </b><%= termsofdelivery%><br/>
                  <b>&nbspAttention :- </b><%= attention %></td></tr>
              </table>  </div>

它将解决您的问题。如果您有任何其他问题,请告诉我。感谢