前端界面小作业,五彩导航。

代码:

<!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>

效果图:

点击后颜色还会随之变化

图片资源:

 见文章绑定资源。

源码:

http://t.csdnimg.cn/PsYSe

大佬那里没找到图片我封一下。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐