前端界面小作业,五彩导航。
代码:
<!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>五彩导航</title>
<style>
/* 设置导航链接样式 */
.nav a {
display: inline-block;
width: 120px;
height: 58px;
text-align: center;
line-height: 48px;
text-decoration: none;
color: white; /* 将文字颜色设为白色 */
}
</style>
<style>
/* 设置导航背景样式 */
.nav a {
display: inline-block;
width: 120px;
height: 58px;
/* background-color: blue; */
text-align: center;
line-height: 48px;
/* color: red; */
text-decoration: none;
}
/* 设置不同背景图片及鼠标悬停效果 */
.nav .bg1 {
background: url(../五彩导航/red.jpg) no-repeat;
}
.nav .bg1:hover {
background-image: url(../五彩导航/orange.jpg);
}
.nav .bg2 {
background: url(../五彩导航/green.jpg) no-repeat;
}
.nav .bg2:hover {
background-image: url(../五彩导航/lightblue.jpg);
}
.nav .bg3 {
background: url(../五彩导航/blue.jpg) no-repeat;
}
.nav .bg3:hover {
background-image: url(../五彩导航/pink.jpg);
}
.nav .bg4 {
background: url(../五彩导航/pink.jpg) no-repeat;
}
.nav .bg4:hover {
background-image: url(../五彩导航/purple.jpg);
}
</style>
</head>
<body>
<div class="nav">
<a href="https://gitee.com/" class="bg1">Gitee</a>
<a href="http://i.chaoxing.com/base?t=1684309667828" class="bg2">超星学习通</a>
<a href="https://hxxy.imnu.edu.cn/info/1081/2853.htm" class="bg3">人物介绍</a>
<a href="https://github.com/Huang-tongxue/Pretiece-Huang" class="bg4">GitHub</a>
</div>
</body>
</html>
效果图:
点击后颜色还会随之变化
图片资源:
见文章绑定资源。
源码:
大佬那里没找到图片我封一下。