製作首頁時,表格的使用頻率非常高,靈活運用種種技巧能為網頁增色不少。以下就詳細介紹幾種特效表格的做法。
<style type="text/css">
<!--
.tab1 {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: dotted;
border-right-style: dotted;
border-bottom-style: dotted;
border-left-style: dotted;
border-top-color: #00CC66;
border-right-color: #0099CC;
border-bottom-color: #FF0000;
border-left-color: #6699FF;
}
-->
</style>
<table width="200" border="0" cellpadding="2" cellspacing="2" class="tab1">
<tr>
<td><div align="center">虛</div></td>
<td><div align="center">線</div></td>
</tr>
<tr>
<td><div align="center">表</div></td>
<td><div align="center">格</div></td>
</tr>
</table>
關鍵在於用四邊不同顏色的 dotted 虛線,營造出繽紛活潑的視覺層次。
onmouseout="this.style.backgroundColor=''" 是滑鼠移出的效果;onmouseover="this.style.backgroundColor='#FFcccc'" 則是滑鼠移入的効果,只要替換 #FFcccc 的色值即可自訂顏色。
<table width="200" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFcccc'"> </td>
</tr>
<tr>
<td onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFccaa'"> </td>
</tr>
</table>
只要為不同儲存格指定不同色值,就能做出多變的互動回饋,讓表格不只是靜態排列,還能回應使用者的操作。