国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

CSSオンラインマニュアル / CSS 鏈接(link)

CSS 鏈接(link)

CSS 鏈接


不同的鏈接可以有不同的樣式。


鏈接樣式

鏈接的樣式,可以用任何CSS屬性(如顏色,字體,背景等)。

特別的鏈接,可以有不同的樣式,這取決于他們是什么狀態(tài)。

這四個鏈接狀態(tài)是:

  • a:link - 正常,未訪問過的鏈接

  • a:visited - 用戶已訪問過的鏈接

  • a:hover - 當(dāng)用戶鼠標(biāo)放在鏈接上時

  • a:active - 鏈接被點(diǎn)擊的那一刻

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
a:link {color:#FF0000;}    /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;}   /* mouse over link */
a:active {color:#0000FF;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">這是一個鏈接</a></b></p>
<p><b>注意:</b> a:hover 必須在 a:link 和 a:visited 之后,需要嚴(yán)格按順序才能看到效果。</p>
<p><b>注意:</b> a:active 必須在 a:hover 之后。</p>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

當(dāng)設(shè)置為若干鏈路狀態(tài)的樣式,也有一些順序規(guī)則:

  • a:hover 必須跟在 a:link 和 a:visited后面

  • a:active 必須跟在 a:hover后面


常見的鏈接樣式

根據(jù)上述鏈接的顏色變化的例子,看它是在什么狀態(tài)。

讓我們通過一些其他常見的方式轉(zhuǎn)到鏈接樣式:

文本修飾

text-decoration 屬性主要用于刪除鏈接中的下劃線:

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
a:link {text-decoration:none;}    /* unvisited link */
a:visited {text-decoration:none;} /* visited link */
a:hover {text-decoration:underline;}   /* mouse over link */
a:active {text-decoration:underline;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This is a link</a></b></p>
<p><b>注意:</b> hover必須在:link和 a:visited之后定義才有效.</p>
<p><b>注意:</b>active必須在hover之后定義是有效的.</p>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

背景顏色

background-color屬性指定鏈接背景色:

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
a:link {background-color:#B2FF99;}    /* unvisited link */
a:visited {background-color:#FFFF85;} /* visited link */
a:hover {background-color:#FF704D;}   /* mouse over link */
a:active {background-color:#FF704D;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This is a link</a></b></p>
<p><b>注意:</b> hover必須在:link和 a:visited之后定義才有效.</p>
<p><b>注意:</b>active必須在hover之后定義是有效的.</p>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例


更多實(shí)例

實(shí)例: 添加不同樣式的超鏈接

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}

a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}

a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}

a.four:link {color:#ff0000;}
a.four:visited {color:#0000ff;}
a.four:hover {font-family:monospace;}

a.five:link {color:#ff0000;text-decoration:none;}
a.five:visited {color:#0000ff;text-decoration:none;}
a.five:hover {text-decoration:underline;}
</style>
</head>

<body>
<p>將鼠標(biāo)移至鏈接上改變樣式.</p>

<p><b><a class="one" href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This link changes color</a></b></p>
<p><b><a class="two" href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This link changes font-size</a></b></p>
<p><b><a class="three" href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This link changes background-color</a></b></p>
<p><b><a class="four" href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This link changes font-family</a></b></p>
<p><b><a class="five" href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This link changes text-decoration</a></b></p>
</body>

</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

這個例子演示了如何為超鏈接添加其他樣式。

實(shí)例:高級 - 創(chuàng)建鏈接框

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
a:link,a:visited
{
	display:block;
	font-weight:bold;
	color:#FFFFFF;
	background-color:#98bf21;
	width:120px;
	text-align:center;
	padding:4px;
	text-decoration:none;
}
a:hover,a:active
{
	background-color:#7A991A;
}
</style>
</head>

<body>
<a href="http://miracleart.cn/css/css-css_tutorial.html" target="_blank">This is a link</a>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

這個例子演示了一個更高級的例子,我們結(jié)合若干CSS屬性顯示為方框。