1. 程式人生 > >24, CSS 構造超鏈接

24, CSS 構造超鏈接

link com 14. 段落 ali phy 突出 lac .org

1. 超鏈接邊框

2. 派生超鏈接

3. 屬性選擇器超鏈接

4. 動態超鏈接

5. 圖像翻轉超鏈接

6. CSS 工具提示

1.給鏈接加上邊框

A:link {

Color: #f00;

Text-decoration: none;

Border-bottom: 1px dashed #333;

Line-height: 150%;

}

2.在文章段落中加上超級鏈接

A:link {

Color: #f00;

Text-decoration: none;

Border: 1px solid #333;

Background: #ccc;

Padding: 2px;

Line-height: 150%;

}

3. 用背景圖象添加記號

A:link {

Color:#f00;

Padding: 0 15px 0 0;

Background:url(images/arrow.gif) no-repeat right center;

}

A:visited {

Color:#999;

Padding: 0 15px 0 0;

Background:url(images/checkmark.gif) no-repeat right center;

}

4.利用派生來影響鏈接

P a:link, p a:visited, p a:hover, p a:active {

Color:#f00;

}

Ul a{

Color:#000;

}

5.利用圖片作為下劃線

A:link, a:visited {

Color: #666;

Text-decoration:none;

Background: url(images/underline1.gif) repeat-x left bottom;

}

A:hover, a:active {

Background:url(images/underline1-hover.gif);

}

6.突出顯示不同類型的鏈接

.external {

Background:url(images/externalLink.gif) no-repeat right top;

Padding-right: 10px;

}

7.使用屬性選擇器來做鏈接

a[href^="http:"] {

background:url(images/externalLink.gif) no-repeat right top;

padding-right: 10px;

}

a[href^="mailto:"] {

background:url(images/email.png) no-repeat right top;

padding-right: 13px;

}

8.創建按鈕和翻轉

a {

Display: block;

Width: 6em;

Padding: 02.em;

Line-height: 1.4;

Background-color: #94b8e9;

Border: 1px solid black;

Color: #000;

Text-decoration: none;

Text-align: center;

}

a:hover {

background-color: #369;

color:#fff;

}

9.具有圖象的翻轉

a {

Display: block;

Width: 200px;

Height: 40px;

Line-height: 40px;

Background-color: #94b8e9;

Color: #000;

Text-decoration: none;

Text-indent:50px;

Background: #94b8ea url(images/button.gif) no-repeat left top;

}

A:hover {

Background: #369 url(images/button_over.gif) no-repeat left top;

Color: #fff;

}

9.以訪問鏈接樣式

<ul>

<li><a href="http://www.andybudd.com/">Andy Budd‘s Blogography</a></li>

<li><a href="http://www.stuffandnonsense.co.uk/">Stuff and Nonsense</a></li>

<li><a href="http://www.hicksdesign.co.uk/journal/">Hicks Design</a></li>

<li><a href="http://www.clagnut.com/">Clagnut</a></li>

<li><a href="http://www.htmldog.com/">HTML Dog</a></li>

<li><a href="http://adactio.com/journal/">Adactio</a></li>

<li><a href="http://www.allinthehead.com/">All In TheHead</a></li>

<li><a href="http://www.markboulton.co.uk/journal/">Mark Boulton</a></li>

<li><a href="http://www.ian-lloyd.com/">Ian Lloyd</a></li>

</ul>

ul {

list-style:none;

}

li {

margin: 5px 0;

}

li a {

display: block;

width: 300px;

height: 30px;

line-height: 30px;

color: #000;

text-decoration: none;

background: #94B8E9 url(images/visited.gif) no-repeat left top;

text-indent: 10px;

}

li a:visited {

background-position: right top;

}

10.css 工具提示

<p>

<a href="http://www.andybudd.com/" class="tooltip">Andy Budd<span> (This website

rocks) </span></a> is a web developer basedin Brighton England.

</p>

a.tooltip {

position: relative;

}

a.tooltip span {

display: none;

}

a.tooltip:hover {

font-size: 100%; /* Fixes bug in IE5.x/Win */

}

a.tooltip:hover span {

display:block;

position:absolute;

top:1em;

left:2em;

padding: 0.2em 0.6em;

border:1px solid #996633;

background-color:#FFFF66;

color:#000;

}

1CSS構造超鏈接給鏈接加上邊框

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS構造超鏈接給鏈接加上邊框</title>
<style type="text/css">
	a{
		text-decoration: none;
		color: red;
		border-bottom: 1px dashed #333;
		background: red;
		display: block;
		width: 160px;
		line-height: 150%;
	}
	</style>
</head>

<body>
<div>
<ul>
<li><a href="#">CSS構造超鏈接給鏈接加上邊框</a></li>
<li><a href="#">CSS構造超鏈接給鏈接加上邊框</a></li>
<li><a href="#">Spirits</a></li>
<li><a href="#">Cola</a></li>
<li><a href="#">Lemonade</a></li>
<li><a href="#">Tea</a></li>
<li><a href="#">Coffee</a></li>
</ul>
</div>
</body>
</html>

  2在文章段落中加上超級鏈接

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在文章段落中加上超級鏈接</title>
<style type="text/css">
	a{
		border: 1px solid #333;
		background: #ccc;
		text-decoration: none;
		color: #f00;
		line-height: 150%;
		
	}
	</style>
</head>

<body>
<div>

<p>在文章段落中加上超級鏈接1<a href="#">在文章段落中加上超級鏈接2</a>在文章段落中加上超級鏈接3</li>


</div>
</body>
</html>

  3用背景圖象添加記號1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在文章段落中加上超級鏈接</title>
<style type="text/css">
	a{
	    
		background:url(images/2.jpg) no-repeat left center;
		text-decoration:none;
		color: #f00;
		line-height:150%;
		padding-left:15px;
		
	}
	</style>
</head>

<body>
<div>

<p>在文章段落中加上超級鏈接1<a href="#">在文章段落中加上超級鏈接2</a>在文章段落中加上超級鏈接3</li>


</div>
</body>
</html>

  3用背景圖象添加記號2.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用背景圖象添加記號</title>
<style type="text/css">
	a{
	    background:url(images/2.jpg) no-repeat left center;
		text-decoration:none;
		color: #f00;
		line-height:150%;
		padding-left:15px;
		
	}
	a:hover{
		background: url(images/8.png) no-repeat left center;
	}
	</style>
</head>

<body>
<div>

<p>用背景圖象添加記號1<a href="#">用背景圖象添加記號2</a>用背景圖象添加記號3</p>


</div>
</body>
</html>

  4利用派生來影響鏈接

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>利用派生來影響鏈接</title>
<style type="text/css">
	a:link,a:visited,a:active,a:hover{
	    
		background:url(images/2.jpg) no-repeat left center;
		text-decoration:none;
		color: #f00;
		line-height:150%;
		padding-left:15px;
		
	}
	a:visited{
		background: url(images/8.png);
	}
	</style>
</head>

<body>
<div>

<p>利用派生來影響鏈接1<a href="#">利用派生來影響鏈接2</a>利用派生來影響鏈接3</p>


</div>
</body>
</html>

  5利用圖片作為下劃線

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>利用圖片作為下劃線</title>
<style type="text/css">
	a{	    
		background:url(images/11.png) repeat-x left bottom;
		text-decoration: none;
		}
	a:hover{
		background:url(images/12.png) repeat-x left bottom;
	}
	</style>
</head>

<body>
<div>

<p>利用圖片作為下劃線1<a href="#">利用圖片作為下劃線2</a>利用圖片作為下劃線3</p>


</div>
</body>
</html>

  6突出顯示不同類型的鏈接

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>突出顯示不同類型的鏈接</title>
<style type="text/css">
	a{	    
		color:red;
		
		}
	a:hover{
		color:blue;
	}
	.ex{
		color: green;
		background: url(images/8.png) no-repeat left center;
		padding: 10px;
	}
	</style>
</head>

<body>
<div>

<p>突出顯示不同類型的鏈接1<a href="#">突出顯示不同類型的鏈接2</a>突出顯示不同類型的鏈接3<a href="#" class="ex">突出顯示不同類型的鏈接2</a></p>


</div>
</body>
</html>

  7使用屬性選擇器來做鏈接

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>使用屬性選擇器來做鏈接</title>
<style type="text/css">
	a[href^="http:"]{
		background: url(images/8.png) no-repeat left center;
		padding-left: 10px;
		color: red;
	}
	a[href^="mailto:"]{
		background: url(images/2.jpg) no-repeat left center;
		padding-left: 10px;
		color: green;
	}
	
	</style>
</head>

<body>
<div>

<div>屬性選擇器來做鏈接1<a href="#">使用屬性選擇器來做鏈接2</a>使用屬性選擇器來做鏈接3<a href="http://www.baidu.com">性選擇器來做鏈接3<a href="mailto:[email protected]">使用屬性選擇器來做鏈接</a></div>


</div>
</body>
</html>

  8創建按鈕和翻轉

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>創建按鈕和翻轉</title>
<style type="text/css">
	a {
Display: block;
Width:160px;
Padding: 02.em;
Line-height: 1.4;
Background-color: #94b8e9;
Border: 1px solid black;
Color: #000;
Text-decoration: none;
Text-align: center;
}
a:hover {
background-color: #369;
color:#fff;
}
	
	</style>
</head>

<body>
<div>

<div>創建按鈕和翻轉1<a href="#">創建按鈕和翻轉2</a>創建按鈕和翻轉3<a href="http://www.baidu.com">創建按鈕和翻轉3<a href="mailto:[email protected]">創建按鈕和翻轉</a></div>


</div>
</body>
</html>

  9按鈕具有圖象的翻轉

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>按鈕具有圖象的翻轉</title>
<style type="text/css">
	a {
Display: block;
Width:200px;
height: 44px;
Line-height:40px;
Background:url(images/13.png);
font-size: 12px;
Color: #000;
Text-decoration: none;
Text-align: center;
}
a:hover {
Background:url(images/14.png);
color:#fff;
}
	
	</style>
</head>

<body>
<div>

<div>按鈕具有圖象的翻轉1<a href="#">按鈕具有圖象的翻轉2</a>按鈕具有圖象的翻轉3<a href="http://www.baidu.com">按鈕具有圖象的翻轉3<a href="mailto:[email protected]">按鈕具有圖象的翻轉</a></div>


</div>
</body>
</html>

  10以訪問鏈接樣式

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>按鈕具有圖象的翻轉</title>
<style type="text/css">
	ul{
	list-style-type: none;
	
	}
	ul li{
		height: 25px;
	}
	ul li a{
		width: 260px;
		height:30px;
		line-height: 30px;
		display: block;
		background: url(images/16.png) no-repeat left center;
		padding-left:30px;
		color: red;
	}
	ul li a:visited{
	color: maroon;
	background: url(images/15.png) no-repeat left center;
	}
	</style>
</head>

<body>
<ul>
	<li><a href="http://www.andybudd.com/">Andy Budd‘s Blogography</a></li>
	<li><a href="http://www.stuffandnonsense.co.uk/">Stuff and Nonsense</a></li>
	<li><a href="http://www.hicksdesign.co.uk/journal/">Hicks Design</a></li>
	<li><a href="http://www.clagnut.com/">Clagnut</a></li>
	<li><a href="http://www.htmldog.com/">HTML Dog</a></li>
	<li><a href="http://adactio.com/journal/">Adactio</a></li>
	<li><a href="http://www.allinthehead.com/">All In TheHead</a></li>
	<li><a href="http://www.markboulton.co.uk/journal/">Mark Boulton</a></li>
	<li><a href="http://www.ian-lloyd.com/">Ian Lloyd</a></li>
</ul>
</body>
</html>

  11純 css 工具提示一段文字1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>純 css 工具提示</title>
<style type="text/css">
	body{
	margin: 100px;
	}
	p a{
		position: relative;
	}
	p a span{
	display: none;
	}
	p a:hover span{
		position: absolute;
		top: 20px;
		left: 0px;
		display:block;
		border: 1px solid black;
		width:150px;
		height;100px;
		background: lightyellow;
	}
	p a:hover{
		font-size: 100%;
	}
	</style>
</head>

<body>
<p>
	<a href="http://www.baidu.com">純 css 工具提示<span>純 css 工具提示</span>具提示純 css 工具提示
		
	</a>
</p>
</body>
</html>

  11純 css 工具提示一張圖片2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>純 css 工具提示</title>
<style type="text/css">
	body{
	margin: 100px;
	}
	p a{
		position: relative;
	}
	p a span{
	display: none;
	}
	p a:hover span{
		position: absolute;
		top: 20px;
		left: 0px;
		display:block;
		border: 1px solid black;
		width:150px;
		height;100px;
		background: lightyellow;
	}
	p a:hover{
		font-size: 100%;
	}
	</style>
</head>

<body>
<p>
	<a href="http://www.baidu.com">純 css 工具提示<span>純 css 工具提示<br/><img src="images/pic7.jpg"</span>具提示純 css 工具提示
		
	</a>
</p>
</body>
</html>

  

24, CSS 構造超鏈接