2011-05-10 120 views
0

垂直滾動起作用,但水平不起作用。我的代碼:div的水平滾動不起作用

<html > 

<body > 
    <table style=" height:100%; width:100%"> 
     <tr> 
      <td > 
       <div style=" overflow:scroll; height:100%; width:100%">  
        <table style=" width:2000px; height:2000px; "> 
        <tr><td></td></tr> 
        </table>  
       </div> 
      </td> 
     </tr> 
    </table> 
</body> 
</html> 
+0

您正在嘗試表格樣式與嵌套表...它永遠不會去真的很好。我建議你尋找一個「CSS教程」。在哪個瀏覽器中使用 – lpd 2011-05-10 10:47:27

+0

?我認爲在所有瀏覽器中工作正常。 – 2011-05-10 10:52:02

+0

互聯網瀏覽器 – 2011-05-10 11:06:41

回答

0

表不是要使用的理想元素,除非你想顯示一個表/目錄。 總是比表格更喜歡div。 這應該做烏爾<體>

<div style="height: 100%; width: 100%"> 
     <div style="overflow: scroll; height: 100%; width: 100%"> 
      <table style="width: 2000px; height: 2000px;"> 
       <tr> 
        <td> 
        </td> 
       </tr> 
      </table> 
     </div> 

隨着表中,U必須設置表格的佈局裏面:固定,

<table style="height: 100%; width: 100%; table-layout:fixed"> 
     <tr> 
      <td> 
       <div style="overflow: scroll; height: 100%; width: 100%"> 
        <table style="width: 2000px; height: 2000px;"> 
         <tr> 
          <td style="width:50%; display:none"> 
          </td> 

          <td style="width:50%; display:none"> 
          </td>      
         </tr> 
         <tr> 
           <td>control here will auto-align to 50%</td> 
           <td>control here will auto-align to 50%</td> 
         </tr> 
        </table> 
        </div> 
      </td> 
     </tr> 
    </table> 

我已經修改了TD模板。請注意,以及。

+0

我的html是非常大的地方使用大量的表格,爲什麼它不在表內工作 – 2011-05-10 11:04:55

+0

該表格在差異瀏覽器中表現不同。因此,對於表格100%的寬度將在某些瀏覽器中佔用100%的容器,而在某些其他瀏覽器中則佔100%。如果你想堅持桌子,你必須告訴瀏覽器,留在容器中...更新我的解決方案..希望這有助於..(注意:這可能會影響td樣式,所以這期望所有的tds是相同的寬度。) – Raghav 2011-05-10 11:20:27

+0

感謝它爲我工作 – 2011-05-10 11:42:17

0

我改變了你這樣的代碼

<html > 
<body > 
    <table style=" height:100%; width:100%"> 
     <tr> 
      <td > 
       <div style=" overflow:scroll; height:2000px; width:100%">  
        <table style=" width:2000px; height:2000px; overflow:scroll;"> 
        <tr><td></td></tr> 
        </table>  
       </div> 
      </td> 
     </tr> 
    </table> 
</body> 
</html> 

嘗試this.it將工作..