为导航链接添加活动/当前状态
实例代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
ul{
list-style-type:none;
margin:0;
padding:0;
}
a.active{
background-color:green;
}
li a {
background-color:#cccccc;
width:100px;
display:block;
padding:8px 16px;
text-decoration:none;
}
li a:hover{
background-color:#555;
color:white;
}
</style>
</head>
<body>
<h1>垂直导航栏</h1>
<p>在此例中,我们创建一个具有绿色背景色和白色文本的“active”类。文类将添加到“home”链接</p>
<ul>
<li><a class="active "href="https://www.dwoke.com">首页</a></li>
<li><a href="https://www.dwoke.com">文章</a></li>
<li><a href="https://www.dwoke.com">下载</a></li>
<li><a href="https://www.dwoke.com">文档</a></li>
<li><a href="https://www.dwoke.com">关于</a></li>
</ul>
</body>
</html>
运行效果:
评论