博客列表 >纯css丝带导航

纯css丝带导航

虞者自愚的博客
虞者自愚的博客原创
2018年05月06日 22:36:31897浏览

代码


实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>css丝带导航</title>
    <style type="text/css">
        body,div,ul,li{margin:0;padding:0;font-family: '微软雅黑';}  /* 样式重置 */
        body {background-color:#444;}
        .nav{
            width:450px;
            height:50px;
            background-color:#fff;
            margin:200px auto 0;
            position:relative;
        }
       .nav .left{
            position:absolute;
            left:-18px;
            top:8px;
            width:36px;
            height:36px;
            background-color:#444;
            transform:rotate(45deg); /* 旋转45度 */

        }
        .nav .right{
            position:absolute;
            right:-18px;
            top:8px;
            width:36px;
            height:36px;
            background-color:#444;
            transform:rotate(45deg); /* 旋转45度 */

        }
        .nav ul{
            position:relative;
            top:-10px;
            width:350px;
            height:60px;
            margin:0 auto;
            overflow:hidden;
            display:flex;

        }
        .nav ul li {
            position:relative;
            top:10px;
            width:70px;
            height:50px;
            line-height:50px;
            text-align:center;
            background-color:#fff;
            transition: .4s;
            list-style: none;
            box-shadow:0 20px 0 -10px #444;
            cursor:pointer;
        }
        .nav ul li:hover {
        top:0;
        background-color:yellow;
        border-radius:3%;

        }
        .nav ul li:before {
            position:absolute;
            top:50px;
            display:block;
            content: '';
            width:10px;
            height:10px;
            background-image:linear-gradient(45deg,#fff 50%,#ccc 50%);
        }
        .nav ul li:after {
            position:absolute;
            top:50px;
            right:0;
            display:block;
            content: '';
            width:10px;
            height:10px;
            background-image:linear-gradient(-45deg,#fff 50%,#ccc 50%);
        }

    </style>
</head>
<body>
<div class="nav">
<div class="left"></div>
<ul>
    <li>HOME</li>
    <li>HOME</li>
    <li>HOME</li>
    <li>HOME</li>
    <li>HOME</li>
</ul>
<div class="right"></div>
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例




今天在网上看到的一个这样的导航,觉得挺好看的,就自己写了下来

相对定位与绝对定位,包括伪类的使用,重在理解过程

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议