«

标题栏三角形按钮小案例

时间:2023-5-6 16:51     作者:吾峰     分类: 前端开发


<!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: 100px;
            height: 50px;
            line-height: 50px;
            background: lightskyblue;
            text-indent: 20px;
        }

        /* 默认上三角形 */
        span {
            display: inline-block;
            width: 0;
            height: 0;
            /* 上边框5px白色,其他边框隐形 */
            border: 5px solid transparent;
            border-top: 5px solid white;
            position: relative;
            /* 上三角形下移居中 */
            top: 2.5px;
        }

        /* 鼠标滑过显示下三角形 */
        .box:hover span {
            border: 5px solid transparent;
            /* 下边框显示 */
            border-bottom: 5px solid white;
            position: relative;
            /* 下三角形上移居中 */
            top: -2.5px;
        }
    </style>
</head>
<body>
    <div class="box">
        导航
        <span></span>
    </div>
</body>
</html>

默认上三角,鼠标滑过显示下三角

标签: html css


扫描二维码,在手机上阅读