2013-08-27 33 views
1

我有這個簡單的HTML表格。html簡單對齊,在表格和頁面中

<table align="center" border="1" cellpadding="0" cellspacing="0" style="width:1000px"> 
    <thead> 
     <tr> 
      <th scope="row">BB<br /> 
      BB<br /> 
      BB</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
     </tr> 
    </thead> 
    <tbody> 
    </tbody> 
</table> 

<p>&nbsp;</p> 

但是我希望AA細胞在垂直方向排列(現在它的排列中心垂直)。 而且我想要表格上方的空間並將表格留空。

在html中呈現簡單的代碼我會理解我的意思。

現在我想鏈接一個簡單的CSS來使這個功能,但我怎麼能做到這一點?

更新,在CSS的解決方案是:

th{ 
vertical-align:top; 
} 
body 
{ 
    margin: 0; 
    padding: 0; 
} 

THX。

回答

1

您可以只針對使用以下CSS含aa細胞:

th[scope="col"] { 
    vertical-align: top; 
} 

這是jsFiddle demo

+0

thx,但我怎樣才能從上面刪除空間並離開桌子? – user2670708

+0

將body上的填充設置爲0:'body {padding:0}'。 – BenM

2

試試這個

th{ 
vertical-align:top; 
} 

或只爲AA

th[scope="col"]{ 
vertical-align:top; 
} 
+0

thx,但我怎樣才能從上面刪除空間並離開桌子? – user2670708

+0

你可以sh我屏幕拍攝 –

0

試試這個。

<table align="center" border="1" cellpadding="0" cellspacing="0" style="width:1000px"> 
    <thead> 
     <tr style="vertical-align: top;"> 
      <th scope="row">BB<br /> 
      BB<br /> 
      BB</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
      <th scope="col">AA</th> 
     </tr> 
    </thead> 
    <tbody> 
    </tbody> 
</table> 

<p>&nbsp;</p>