一、Html前端鼠标滑过控制内容展示

方案1,使用Hover伪类控制元素内部展示和隐藏

一般遇到会遇到问题的代码如下,初学者常遇到:

1.弹出层在z轴顺序问题,z-index

2.鼠标滑过按钮和展示内容中间,弹出层隐藏问题

<!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>
        a {
            color: inherit;
            text-decoration: none;
        }

        .list {
            border: 1px solid red;
            padding: 15px 50px;
        }

        .list .item {
            background: blueviolet;
            color: white;
            width: 100px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            position: relative;
            z-index: 10;
            margin-bottom: 30px;
        }

        .list .item:hover {
            background: rgb(116, 25, 201);
        }

        .list .item:hover .prop {
            display: block;
        }

        .list .item a {
            display: block;
        }

        .prop {
            border: 0px solid blue;
            background: white;
            color: black;
            padding: 15px 20px;
            width: 150px;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            text-align: left;
            box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.3);
            border-radius: 5px;
            z-index: 100;
            top: 52px;
            display: none;
        }

        .prop .angile {
            width: 30px;
            height: 30px;
            border: 1px solid #ddd;
            border-right: 0px;
            border-bottom: 0px;

            position: absolute;
            top: -15px;
            background: white;
            left: 50%;
            transform: translateX(-50%) rotate(45deg);
            z-index: -1;
        }

        .prop .title {
            font-size: 16px;
        }

        .prop .keywords {
            font-size: 13px;
            color: #aaa;
        }
        
    </style>
</head>

<body>
    <!-- HTML鼠标滑过显示内容处理 -->
    <div class="list">
        <div class="item">
            <a href="http://www.jnqianle.cn" target="_blank">千乐微云</a>

            <div class="prop">

                <div class="title">济南小程序开发</div>
                <div class="keywords">济南小程序开发,济南网站开发,济南App开发</div>
                <div class="angile"></div>
            </div>
        </div>

        <div class="item">
            <a href="http://www.jnqianle.cn" target="_blank">千乐微云</a>

            <div class="prop">

                <div class="title">济南小程序开发</div>
                <div class="keywords">济南小程序开发,济南网站开发,济南App开发</div>
                <div class="angile"></div>
            </div>
        </div>
        <div class="item">
            <a href="http://www.jnqianle.cn" target="_blank">千乐微云</a>

            <div class="prop">

                <div class="title">济南小程序开发</div>
                <div class="keywords">济南小程序开发,济南网站开发,济南App开发</div>
                <div class="angile"></div>
            </div>
        </div>
    </div>
</body>

</html>
View Code

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案