声明:以下内容为个人学习总结,初衷是方便自己学习复习记录。如有错误之处,烦请多多指正!
简单导航栏的实现效果:
具体代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
a{
text-decoration: none;
/*使a元素从行内元素变为块状元素,从而设置宽和高*/
display: inline-block;
width: 80px;
height: 35px;
/*高度等于行高,文字垂直方向居中*/
line-height: 35px;
background-color: rgb(101,101,101);
/*文字水平居中*/
text-align: center;
color: white;
}
a:hover {
background-color: rgb(201,192,211);
color: rgb(101,101,101);
}
</style>
</head>
<body>
<a href="#">首页</a>
<a href="#">前端</a>
<a href="#">后端</a>
<a href="#">工具使用</a>
<a href="#">关于我</a>
</body>
</html>