[CSS Animation 09--Full Screen Navigation]

CSS Animation 09--Full Screen Navigation

introduce

full screen

HTML

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>全屏导航栏菜单</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="./css/9.css">
</head>

<body>
    <input type="checkbox" id="menu_btn">
    <label class="menu-btn" for="menu_btn">
        <i class="fa fa-bars" aria-hidden="true"></i>
    </label>
    <div class="con">
        <!-- <h1>全屏覆盖导航栏</h1> -->
        <h3>HTML + CSS【和第7个有点相似】</h3>
    </div>
    <div class="wrapper">
        <ul class="menu">
            <li><a href="#">首页</a></li>
            <li><a href="#">收藏</a></li>
            <li><a href="#">列表</a></li>
            <li><a href="#">咨询</a></li>
            <li><a href="#">我的</a></li>
        </ul>
    </div>
</body>

</html>

CSS

*{
    
    
    /* 初始化 取消页面的内外边距 */
    margin: 0;
    padding: 0;
    /* 这个是告诉浏览器:你想要设置的边框和内边距的值是包含在总宽高内的 */
    box-sizing: border-box;
}
.con{
    
    
    /* 弹性布局 水平、垂直居中 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* 100%的窗口高度 */
    height: 100vh;
    /* 行高 */
    line-height: 80px;
    font-size: 30px;
    /* 字间距 */
    letter-spacing: 15px;
}
.wrapper{
    
    
    /* 固定定位 窗口滚动也不会移动 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 渐变背景 */
    background: linear-gradient(200deg,pink,#7873f5);
    /* 将元素剪切为一个圆形【25px表示圆的直径】【calc(100% - 45px) 45px表示圆心】 */
    clip-path: circle(25px at calc(100% - 45px) 45px);
    /* 过渡动画 */
    transition: all 0.3s ease-in-out;
}
.menu-btn{
    
    
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 2;
    /* 渐变背景 */
    background: linear-gradient(200deg,pink,#7873f5);
    width: 50px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    /* 这里也加个过渡动画 */
    transition: all 0.3s ease;
}
/* 把复选框隐藏 */
#menu_btn{
    
    
    display: none;
}
#menu_btn:checked ~ .wrapper{
    
    
    /* 将元素剪切为一个圆形 75%表示圆的直径 */
    clip-path: circle(75%);
}
#menu_btn:checked ~ .menu-btn{
    
    
    color: pink;
    background: #fff;
}
/* 当复选框为选中态时,改变图标 */
#menu_btn:checked ~ .menu-btn i::before{
    
    
    content: "\f00d";
}
.wrapper ul{
    
    
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    list-style: none;
    text-align: center;
}
.wrapper ul li{
    
    
    margin: 30px 0px;
}
.wrapper ul li a{
    
    
    color: #fff;
    text-decoration: none;
    font-size: 30px;
    font-weight: 500;
    padding: 5px 50px;
    position: relative;
    line-height: 50px;
}
.wrapper ul li a::after{
    
    
    content: "";
    position: absolute;
    width: 100%;
    height: 50px;
    background: #fff;
    z-index: -1;
    border-radius: 50px;
    left: 0px;
    transform: scaleY(0);
    /* 加个动画过渡 */
    transition: transform 0.3s ease;
}
.wrapper ul li a:hover::after{
    
    
    transform: scaleY(1);
}
.wrapper ul li a:hover{
    
    
    color: pink;
}

Guess you like

Origin blog.csdn.net/Clover_zlx/article/details/132429877