2012-06-26 44 views
0

我正在嘗試使用樣式來影響我的html表中單元格的間距。 我正在嘗試使用保證金讓我的單元格僅在右側有空格。 我在做什麼錯了,如何使用樣式來影響單元格間距?嵌入的html風格不影響表?

<html> 
    <head> 
    <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"> 

<style> 
body { 
    font-family: Verdana, Arial, Helvetica, sans-serif; 
    font-size: 9pt; 
} 

table { 
    font-family: Verdana, Arial, Helvetica, sans-serif; 
    font-size: 9pt; 
} 

td { 
    margin: 0px 20px 0px 0px; 
    color: #585858; 
} 

a { 
    color: #326ea1; 
} 
</style> 

    <title>Request</title> 
    </head> 
    <body> 

    <table border="0" cellpadding="0" cellspacing="0"> 
     <tbody> 
     <tr> 
      <td> Request ID </td> 
      <td>516<br> 
      </td> 
     </tr> 
     <tr> 
      <td>Assigned<br> 
      </td> 
      <td>Fred Flintstone<br> 
      </td> 
     </tr> 
     <tr> 
      <td>Requestor<br> 
      </td> 
      <td>Bugs Bunny<br> 
      </td> 
     </tr> 
     <tr> 
      <td>Type<br> 
      </td> 
      <td>Construction<br> 
      </td> 
     </tr> 
     <tr> 
      <td>Location<br> 
      </td> 
      <td>Brazil<br> 
      </td> 
     </tr> 
     <tr> 
      <td> <br> 
      </td> 
      <td> <br> 
      </td> 
     </tr> 
     <tr> 
      <td style=" vertical-align: top;">Description</td> 
      <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, <br> 
       sed do eiusmod tempor incididunt ut labore et dolore <br> 
       magna aliqua. Ut enim ad minim veniam, quis nostrud <br> 
       exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
      </td> 
     </tr> 
     <tr> 
      <td><br> 
      </td> 
      <td><br> 
      </td> 
     </tr> 
     </tbody> 
    </table> 

    </body> 
</html> 
+0

請嘗試使用填充代替? – Danny

回答

1

不幸的是,表格單元格沒有邊距屬性,但您可以在它們上設置填充以獲得所需的行爲。 W3Schools的有造型的表,可以幫助你在這裏的頁面:http://www.w3schools.com/css/css_table.asp

如果你改變你的代碼下面,它應該工作:

td { 
padding: 0px 20px 0px 0px; 
color: #585858; 
} 

您還可以設置在桌子上CELLSPACING屬性。這將在之間的空間的單元格邊框 - 但是,這會影響單元格周圍的間距。

+0

快速簡單!謝謝 – panofish

+0

太棒了!很高興我能幫上忙。 – Andrew