z-index仅能在定位元素上有效

mrgin负值运用,解决产品列表盒子边框合并问题,同时鼠标指上后改变边框状态

<!DOCTYPE html>
<html lang="zh-CN">
<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>
        li {
            position: relative;
            width: 200px;
            height: 300px;
            border: 1px solid pink;
            list-style: none;
            float: left;
            margin-left: -1px;
        }
        li:hover {
            border: 1px solid blue;
            z-index: 1;
        }
    </style>
</head>
<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
</html>

 

posted @ 2022-06-12 09:34  欧阳天天  阅读(20)  评论(0编辑  收藏  举报