纯CSS设置动态导航栏

版权声明:未经同意不得转载 https://blog.csdn.net/qq_42707446/article/details/89847232

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 ">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>drop-down</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background: #66CCCC;
            padding: 40px 0;
            text-align: center;
        }
        .ribbon{
            display: inline-block;
        }
        .ribbon::before{
            margin-top: 8px;
            content: "";
            border: 24px solid #333;
            border-left-color: transparent;
            float: left;
        }
        .ribbon::after{
            margin-top: 8px;
            content: "";
            border: 24px solid #333;
            border-right-color: transparent;
            float: left;
        }
        a{
            float: left;
            height: 56px;
            text-decoration: none;
            overflow: hidden;
        }
        span{
            margin-top: 8px;
            color: #fff;
            line-height:48px;
            padding: 0 16px;
            background: #333;
            display: inline-block;
            position: relative;
            transition: all 0.3s;
        }
        a:hover span{
            margin-top: 0;
            background: #666699;
        }
        span::before{
            content: "";
            position: absolute;
            top: 48px;
            left: 0;
            border-right: 8px solid #666699;
            border-bottom: 8px solid #333;
        }
        span::after{
            content: "";
            position: absolute;
            top:48px;
            right: 0;
            border-left: 8px solid #666699;
            border-bottom: 8px solid #333;
        }
    </style>
</head>
<body>
    <div class="ribbon">
        <a href="#"><span>Home</span></a>
        <a href="#"><span>About</span></a>
        <a href="#"><span>Services</span></a>
        <a href="#"><span>Contact</span></a>
    </div>
    <div style="clear:both;"></div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_42707446/article/details/89847232