td标记内容未对齐

时间:2012-03-07 16:02:27

标签: html alignment html-table

我有一个包含两列的一行表。我想将第二列的内容对齐到右边......我的内容没有正确对齐..你可以检查那里有什么问题......

这是我的代码......

<html><head>                                                                                                                             
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="content-style-type" content="text/css">                                                                                                                <style>

 table td{
 border:1px solid green;
 }

 #Paginator ul{ margin:0px;padding:0px;}
 #Paginator ul li{ font-family::Arial,Tahoma,helvetica,sans-serif;font-size:9pt;list-style:none;float:left;margin:2px;padding:4px 8px 2px 8px;border:1px solid     black;cursor:pointer;}
 #Paginator ul li,#PrevPage{display:none;}
 </style>     

<body>

 <table style="border:1px solid red;width:100%"><tr>
  <td>
    <b style="float:left;">Number of Matching Addresses:&nbsp; 49 &nbspNumber of pages:  5</b>
 </td>

 <td align="right">

 <script>

 var ga_pageId = new Array();
 function pageNavigate(){if(document.getElementById("FromPage")){ var fromPage  = parseInt( document.getElementById("FromPage").value);} if(document.getElementById("ToPage")){var toPage =  parseInt( document.getElementById("ToPage").value);}if(fromPage == 1){document.getElementById("PrevPage").style.display="none";} else{ document.getElementById("PrevPage").style.display="inline"; }if(toPage == 5  || toPage<5){document.getElementById("NextPage").style.display="none";}else{ document.getElementById("NextPage").style.display="inline"; }for(var j=0;j<ga_pageId.length;j++){if(document.getElementById(ga_pageId[j])){document.getElementById(ga_pageId[j]).style.display="none"}}for(var i=fromPage;i<=toPage; i++){ var pageId = 'PAGE_'+i;if(document.getElementById(pageId))document.getElementById(pageId).style.display="inline"; }}

 function previousPage(){var fromPageEle = document.getElementById("FromPage");var toPageEle = document.getElementById("ToPage");if(fromPageEle && toPageEle){fromPageEle.value = parseInt(fromPageEle.value) - 1;toPageEle.value =  parseInt(toPageEle.value) - 1;pageNavigate();}}

 function nextPage(){var fromPageEle = document.getElementById("FromPage");var toPageEle = document.getElementById("ToPage");if(fromPageEle && toPageEle){fromPageEle.value = parseInt(fromPageEle.value) + 1;toPageEle.value =  parseInt(toPageEle.value)  + 1; pageNavigate();}}

 function pageOver(lv_this){if(lv_this.selected!='X')lv_this.style.backgroundColor = "#52CFCF";}
 function pageOut(lv_this){if(lv_this.selected!='X')lv_this.style.backgroundColor = "#E6EFFA";}

 </script>

   <div id="Paginator">
   <input type="hidden" id="FromPage" value="1"/>
   <input type="hidden" id="ToPage" value="5 "/>
    <ul > 

      <li onClick="previousPage()" id="PrevPage"><span>PREV</span></li>
      <script> ga_pageId.push('PAGE_1');</script>

      <li id="PAGE_1">1 </span></li>
      <script> ga_pageId.push('PAGE_2');</script>

      <li id="PAGE_2" >2 </span></li>
      <script> ga_pageId.push('PAGE_3');</script>

      <li id="PAGE_3" >3 </span></li><script> ga_pageId.push('PAGE_4');</script>

      <li id="PAGE_4">4 </span></li>
      <script> ga_pageId.push('PAGE_5');</script>

      <li id="PAGE_5">5 </span>
      </li>
      <li onClick="nextPage()" id="NextPage" style="display:none"><span>NEXT</span></li>
     </ul> </div>

 <script> pageNavigate()</script>

  </td>
  </tr>
</table>

</body></html>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

3 个答案:

答案 0 :(得分:3)

添加此css:

 #Paginator ul{ margin:0px;padding:0px; float:right;}

答案 1 :(得分:1)

您之前的<TD>代码style="float:left;"已经有答案了。 为什么你没有使用第二个<TD>

 You can use the Following options
    1. <td style="float:right;">
    2. <div id="Paginator" style="float:right;" >
    3. #Paginator ul{ margin:0px;padding:0px; float:right;}

答案 2 :(得分:-1)

因为您的内容包含在div中。 div扩展为td的大小,其中的内容左对齐。将text-align: right添加到Paginator ul li样式。