【前端设计】炫酷导航栏

  欢迎来到前端设计专栏,本专栏收藏了一些好看且实用的前端作品,使用简单的html、css语法打造创意有趣的作品,为网站加入更多高级创意的元素。

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="nav.css">
</head>
<body>
    <div class="wrapper">
        <nav>
            <input type="radio" name="tab" id="home" checked>
            <input type="radio" name="tab" id="thumbs">
            <input type="radio" name="tab" id="share">
            <input type="radio" name="tab" id="collection">
            <input type="radio" name="tab" id="comments">
            <label for="home" class="home">
                <a href="#">首页</a>
            </label>
            <label for="thumbs" class="thumbs">
                <a href="#">点赞</a>
            </label>
            <label for="share" class="share">
                <a href="#">分享</a>
            </label>
            <label for="collection" class="collection">
                <a href="#">收藏</a>
            </label>
            <label for="comments" class="comments">
                <a href="#">评论</a>
            </label>
            <div class="active"></div>
        </nav>
    </div>
</body>
</html>

css

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  line-height: 60px;
}
.wrapper {
  height: 60px;
  width: 55vw;
  background-color: #eff;
  box-shadow: 0 6px 16px ;
  box-shadow: 0 6px 16px #0000003f;
  border-radius: 30px;
}

.wrapper nav {
    display: flex;
    position: relative;
}
.wrapper nav label{
    flex: 1;
    cursor: pointer;
    position: relative;
    z-index: 1;
}
.wrapper nav label a{
    color: #1d1f60;
    font-size: 21px;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    z-index: -1;
}
.wrapper nav label a i{
    font-size: 21px;
    margin: 0 6px 0 29px;
}
.wrapper nav .active{
    position: absolute;
    background: linear-gradient(45deg,#06ace0 0%,#8600e6 100%);
    height: 100%;
    width: 20%;
    left: 0;
    bottom: 0;
    border-radius: 30px;
    transition: 0.6s cubic-bezier(0.6, -0.6, 0.26, 1.6);
}
.wrapper nav #home:checked ~ label.home a,
.wrapper nav #thumbs:checked ~ label.thumbs a,
.wrapper nav #share:checked ~ label.share a,
.wrapper nav #collection:checked ~ label.collection a,
.wrapper nav #comments:checked ~ label.comments a{
    color: #fff;
}
.wrapper nav #thumbs:checked ~ .active{
    left: 20%;
}
.wrapper nav #share:checked ~ .active{
    left: 40%; 
}
.wrapper nav #collection:checked ~ .active{
    left: 60%;
}
.wrapper nav #comments:checked ~ .active{
    left: 80%;
}

.wrapper nav input{
    display: none;
}

相关推荐

  1. CSS 导航设计、定制与优化

    2024-02-16 10:54:01       26 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-16 10:54:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-16 10:54:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-16 10:54:01       82 阅读
  4. Python语言-面向对象

    2024-02-16 10:54:01       91 阅读

热门阅读

  1. 《Docker极简教程》--Docker容器--Docker容器的概念

    2024-02-16 10:54:01       56 阅读
  2. 内网穿透与搭建私人服务器

    2024-02-16 10:54:01       48 阅读
  3. 如何使用AIGC才能有利于创新能力的培养

    2024-02-16 10:54:01       55 阅读
  4. Rust Option类型详解

    2024-02-16 10:54:01       54 阅读
  5. Rust 初体验4

    2024-02-16 10:54:01       56 阅读
  6. 如何使用 Python 通过代码创建图表

    2024-02-16 10:54:01       48 阅读
  7. Day35 贪心算法part04

    2024-02-16 10:54:01       48 阅读
  8. Spring boot整合redisson报错

    2024-02-16 10:54:01       53 阅读
  9. idea基础配置

    2024-02-16 10:54:01       54 阅读
  10. ArrayList 与 LinkedList 区别

    2024-02-16 10:54:01       53 阅读
  11. Rust 原生类型

    2024-02-16 10:54:01       51 阅读
  12. SP1:基于Plonky3构建的zkVM

    2024-02-16 10:54:01       59 阅读