侧边伸缩导航栏

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>侧边伸缩导航栏</title>
    <link rel = "stylesheet" href = "https://at.alicdn.com/t/font_2919879_aaakg57syr.css">
	<link rel = "stylesheet" href = "https://at.alicdn.com/t/font_2978232_vsdsu064x6k.css">
	<link rel = "stylesheet" href = "https://at.alicdn.com/t/font_2963692_ao93r6w2bu.css">
    <style>
        *{
            padding: 0;
            margin: 0;
            text-decoration: none;
        }
        /*导航栏整体位置*/
        body{
            display: flex;
            height: 100vh;
            align-items: center;
        }
        /*导航栏整体大小,背景色*/
        .shell{
            width: 20px;
            height: 600px;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
			background: linear-gradient(to top, #9795f0 0%, #fbc8d4 100%);
            border-radius: 0 10px 10px 0px;
            /*导航变宽时的过度时间*/
            transition: 0.3s;
        }
        .box{
            /*变成块级元素*/
            display: block;
            height: 15%;
            width: 85%;
            margin: 9px;
            border-radius: 5px;
            position: relative;
            color: black;
        }
        .shell a i{
            font-size: 20px;
            position: absolute;
            margin: 14px 0 0 7px;
            color: black;
            opacity: 0;
        }
        .shell:hover a i {
            font-size: 20px;
            position: absolute;
            margin: 14px 0 0 7px;
            color: black;
            opacity: 1;
        }
        /*在导航第一个和第五个选项下加横线*/
        .box:nth-child(1)::before,.box:nth-child(5)::before{
            content: '';
            display: block;
            width: 100%;
            height: 2px;
            background-color: rgb(255, 247, 254);
            position: absolute;
            bottom: -10px;
        }
        /*导航文字设置*/
        .box span{
            position: relative;
            top: 14px;
            left: 35px;
            font-size: 15px;
            /*导航收缩下文字透明不显示*/
            opacity: 0;
        }
        /*导航栏变宽*/
        .shell:hover{
            width: 150px;
        }
        /*当鼠标移到某一项时,背景变色*/
        .box:hover{
            background-color: #9795f0;
            color: #fff;
        }
        .box:hover .fa{
            color: #fff;
        }
        /*文字显现*/
        .shell:hover span{
            opacity: 1;
        }
        i{
            font-size:15px;
        }
    </style>
</head>
<body>
    <div class="shell">
        <a href="#" class="box"><i class="iconfont icon-wojia1"  aria-hidden="true"></i><span>首页</span></a>
        <a href="#" class="box"><i class="iconfont icon-gengduo" aria-hidden="true"></i><span>城市迁出人口</span></a>
        <a href="#" class="box"><i class="iconfont icon-gengduo" aria-hidden="true"></i><span>热搜关键词</span></a>
        <a href="#" class="box"><i class="iconfont icon-gengduo" aria-hidden="true"></i><span>政策支持</span></a>
        <a href="#" class="box"><i class="iconfont icon-gengduo" aria-hidden="true"></i><span>世界人口密度</span></a>
        <a href="#" class="box"><i class="iconfont icon-gengduo" aria-hidden="true"></i><span>影响因素</span></a>
        <a href="#" class="box"><i class="iconfont icon-chexiao" aria-hidden="true"></i><span>返回</span></a>
    </div>
</body>
</html>
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值