colspan的定義用法:
colspan 屬性規定單元格可橫跨的列數。
<td colspan="value">
示例代碼:
<html>
<body>
<table width="100%" border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td colspan="2">January</td>
</tr>
<tr>
<td colspan="2">February</td>
</tr>
</table>
</body>
</html>
示例結果:
示例代碼:
<html>
<body>
<table width="100%" border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td colspan="1">January</td>
</tr>
<tr>
<td colspan="1">February</td>
</tr>
</table>
</body>
</html>
示例結果:
border的定義用法:
border 簡寫屬性在一個聲明設置所有的邊框屬性。
可以按順序設置如下屬性:
- border-width
- border-style
- border-color
如果不設置其中的某個值,也不會出問題,比如 border:solid #ff0000; 也是允許的。
可能的值
值 | 描述 |
---|---|
border-width | 規定邊框的寬度。參閱:border-width 中可能的值。 |
border-style | 規定邊框的樣式。參閱:border-style 中可能的值。 |
border-color | 規定邊框的顏色。參閱:border-color 中可能的值。 |
inherit | 規定應該從父元素繼承 border 屬性的設置。 |
border-width可能的值
值 | 描述 |
---|---|
thin | 定義細的邊框。 |
medium | 默認。定義中等的邊框。 |
thick | 定義粗的邊框。 |
length | 允許您自定義邊框的寬度。 |
inherit | 規定應該從父元素繼承邊框寬度。 |
border-style 可能的值
值 | 描述 |
---|---|
none | 定義無邊框。 |
hidden | 與 "none" 相同。不過應用於表時除外,對於表,hidden 用於解決邊框衝突。 |
dotted | 定義點狀邊框。在大多數瀏覽器中呈現爲實線。 |
dashed | 定義虛線。在大多數瀏覽器中呈現爲實線。 |
solid | 定義實線。 |
double | 定義雙線。雙線的寬度等於 border-width 的值。 |
groove | 定義 3D 凹槽邊框。其效果取決於 border-color 的值。 |
ridge | 定義 3D 壟狀邊框。其效果取決於 border-color 的值。 |
inset | 定義 3D inset 邊框。其效果取決於 border-color 的值。 |
outset | 定義 3D outset 邊框。其效果取決於 border-color 的值。 |
inherit | 規定應該從父元素繼承邊框樣式。 |
border-color可能的值
值 | 描述 |
---|---|
color_name | 規定顏色值爲顏色名稱的邊框顏色(比如 red)。 |
hex_number | 規定顏色值爲十六進制值的邊框顏色(比如 #ff0000)。 |
rgb_number | 規定顏色值爲 rgb 代碼的邊框顏色(比如 rgb(255,0,0))。 |
transparent | 默認值。邊框顏色爲透明。 |
inherit | 規定應該從父元素繼承邊框顏色。 |
示例代碼:
<html>
<head>
<style type="text/css">
p //這個p很重要啊,不能沒有
{
border: thick solid rgb(250,0,255)//依次爲三個屬性,邊框寬度、邊框樣式、邊框顏色
}
</style>
</head>
<body>
<p>Some text</p>
</body>
</html>
示例結果:
border-style可以單獨使用
border-style的定義用法:
border-style 屬性用於設置元素所有邊框的樣式,或者單獨地爲各邊設置邊框樣式。
只有當這個值不是 none 時邊框纔可能出現。
示例代碼:
<html>
<head>
<style type="text/css">
p
{
border-style:solid solid double dashed;//四個屬性依次爲上、右、下、左邊框的樣式。可能值在上方。
}
</style>
</head>
<body>
<p>Some text</p>
</body>
</html>
示例結果: