Html中table顯示空單元格的方法及table標簽屬性總結


這段時間因為公司限制域賬戶登錄,在win7下無法上網,就切換到xp系統了,逐漸開始用office2007來發blog,還好基本上我在2010中用到的功能2007都有。

今天在動態生成htm文件時發現自己以前的htm相關知識都忘了,所以要邊用邊搜索,順便總結下。

因為用table顯示查詢統計的表格,所以必須要讓table中空的單元格可以顯示出邊框來,嘗試過有兩種方法:1.<td></td>中間加上&nbsp;,注意不能是直接空格,必須用&nbsp;才可以;2.在table屬性中加入frame="border"。 表格邊框的顯示與隱藏,是可以用frame參數來控制的。請注意它只控制表格的邊框圖,而不影晌單元格。

只顯示上邊框 &lt;table frame=above&gt;<br>

只顯示下邊框 &lt;table frame=below&gt; <br>

只顯示左、右邊框 &lt;table frame=vsides&gt;<br>

只顯示上、下邊框 &lt;table frame=hsides&gt;<br>

只顯示左邊框 &lt;table frame=lhs&gt;<br>

只顯示右邊框 &lt;table frame=rhs&gt;<br>

不顯示任何邊框 &lt;table frame=void&gt;</td>

<table>標簽的屬性設置

帶邊框的表格:
<table border=1 >
<tr><th>Food</th><th>Drink</th><th>Sweet</th>
<tr><td>A</td><td>B</td><td>C</td>
</table>

Food

Drink

Sweet

A

B

C

不帶邊框的表格:
<table> <tr><th>Food</th><th>Drink</th><th>Sweet</th> <tr><td>A</td><td>B</td><td>C</td> </table>

Food

Drink

Sweet

A

B

C

邊框尺寸設置: <table border=#> #=邊框粗度

<table border=10>

<tr><th>Food</th><th>Drink</th><th>Sweet</th>

<tr><td>A</td><td>B</td><td>C</td>

</table>

Food

Drink

Sweet

A

B

C

<table border width=# height=#>width:寬度,height:高度,#=象素
設置表格寬度和高度:
<table border width=170 height=100> <tr><th>Food</th><th>Drink</th><th>Sweet</th> <tr><td>A</td><td>B</td><td>C</td> </table>

Food

Drink

Sweet

A

B

C

<table border cellspacing=#> #=象素

表元間隙設置:
<table border cellspacing=10> <tr><th>Food</th><th>Drink</th><th>Sweet</th> <tr><td>A</td><td>B</td><td>C</td> </table>

Food

Drink

Sweet

A

B

C

<table border cellpadding=#> #=象素
表元內部空白設置:
<table border cellpadding=10> <tr><th>Food</th><th>Drink</th><th>Sweet</th> <tr><td>A</td><td>B</td><td>C</td> </table>

Food

Drink

Sweet

A

B

C

<table align=#> #=left,right,center

設置表格在網頁中的布局位置:

<table align="left" border>

<tr><th>Food</th><th>Drink</th><th>Sweet</th>

<tr><td>A</td><td>B</td><td>C</td>

</table>

My favorites...<br>

cookies, chocolates, and more.

Food

Drink

Sweet

A

B

C

My favorites...
cookies, chocolates, and more.

表格的標題
<caption > 標題內容</caption>
align=left,right,center valign=bottom,top

<table border>

<caption align=center>Lunch</caption>

<tr><th>Food</th><th>Drink</th><th>Sweet</th>

<tr><td>A</td><td>B</td><td>C</td>

</table>

Lunch

Food

Drink

Sweet

A

B

C

表格邊框的色彩
<table bordercolor=#>

<table cellspacing=5 border=5 bodercolor=#ffaa00>

<tr><th>Food</th><th>Drink</th><th>Sweet</th>

<tr><td>A</td><td>B</td><td>C</td>

</table>

Food

Drink

Sweet

A

B

C

表格邊框色彩的亮度控制
<table bordercolorlight=#>
<table bordercolordark=#>

<table
cellspacing=5 border=5

bordercolorlight=blue bordercolordark=Maroon>

<tr><th>Food</th><th>Drink</th><th>Sweet</th>

<tr><td>A</td><td>B</td><td>C</td>

</table>

Food

Drink

Sweet

A

B

C

注意htm中的顏色只能用#RRGGBB表示,比如說黑色就是#000000,而不能像delphi中那樣寫成clBlack(可能沒有定義宏常量的原因)。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM