效果图见下:
具体实现思路:
- 先写两个空连接标签<a href:“#”>,但a是行内元素,如果想实现上述效果,必然要使用行内块display:inline-block,在css中设置
- 之后就是a标签的width height 背景色,以及文字颜色color,下划线去除 text-decoration,文字垂直居中text-algin和line-height
- 这样来我们实现的只有文字和盒子,还没有达到上述效果,要想实现,还要向各个a标签用background:添加图片,然后再用a:hover实现鼠标移动的显示效果
- 效果达成
代码实现:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
a {
display: inline-block;
width: 120px;
height: 58px;
background-color: pink;
color: #fff9ff;
text-decoration: none;
text-align: center;
line-height: 48px;
}
.nav .bg1 {
background: url(images/bg1.png) no-repeat;
}
.nav .bg1:hover {
background-image: url(images/bg11.png);
}
.nav .bg2 {
background: url(images/bg2.png) no-repeat;
}
.nav .bg2:hover {
background-image: url(images/bg22.png);
}
</style>
</head>
<body>
<div class="nav">
<a href="#" class="bg1">五彩导航</a>
<a href="#" class="bg2">五彩导航</a>
</body>
</html>
诶有,终于写完了,今天是坚持写笔记的第二天(肝到寝室熄灯),加油程序猿,明天继续努力