案例:CSS案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style>
5
ul
6
{
7
list-style-type:none;
8
margin:0;
9
padding:0;
10
padding-top:6px;
11
padding-bottom:6px;
12
}
13
li
14
{
15
display:inline;
16
}
17
a:link,a:visited
18
{
19
font-weight:bold;
20
color:#FFFFFF;
21
background-color:#98bf21;
22
text-align:center;
23
padding:6px;
24
text-decoration:none;
25
text-transform:uppercase;
26
}
27
a:hover,a:active
28
{
29
background-color:#7A991A;
30
}
31
32
</style>
33
</head>
34
35
<body>
36
<ul>
37
<li><a href="#home">Home</a></li>
38
<li><a href="#news">News</a></li>
39
<li><a href="#contact">Contact</a></li>
40
<li><a href="#about">About</a></li>
41
</ul>
42
43
<p><b>注释:</b>如果您只为 a 元素设置内边距(而不设置 ul 元素),那么链接会出现在 ul 元素之外。所以,我们为 ul 元素添加了 top 和 bottom 内边距。</p>
44
</body>
45
</html>
46