纯css写三角形与面包屑标题

176 阅读1分钟

纯css写三角形

主要是利用边框border属性加上transparent透明属性实现的效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三角形</title>
    <style>
        /* div{
            display: flex;
        } */
        
        
        .box{
            width: 0px;
            height: 0px;
            border: 50px solid;
            border-color: transparent transparent transparent red;
        }
    </style>
</head>
<body>
    <div>
        
        <div class="box"></div>
    </div>
    
</body>
</html>

image.png

面包屑标题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 400px;
            height: 40px;
            
            position: absolute;
            top: 0;left: 0;
            bottom: 0;right: 0;
            margin:auto;
        }
        .box ul{    
            height: 40px;
            display: flex;
            justify-content: space-evenly;
            align-items: center;
            list-style: none;
            margin: 0;
            padding: 0;
        }
        .box ul li{
            padding: 0 10px;
        }
        ul li a{
            text-decoration: none;
            font-size: 18px;
            color: #777;
            line-height: 30px;
            transform: all 0.5s;
        }
        ul li:hover a{
            color: royalblue;
            
        }
        ul li a::after{
            content: "";
            display: block;
            width: 100%;
            height: 3px;
            border-radius: 10px;
            background: royalblue;
            margin-top: 4px;
            transform: scale(0);
            transition: all 0.5s;
        }
        ul li:hover a::after{
            transform: scale(1);
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li><a href="">关于我们</a></li>
            <li><a href="">产品介绍</a></li>
            <li><a href="">公司介绍</a></li>
            
        </ul>
    </div>
</body>
</html>

image.png