css z-index

注意:

1、z-index的值与大则越近

2、z-index要想生效,必须先定位

3、默认自定义z-index,而不是使用默认的值

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>z-index</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .c1{
            height: 100px;
            width: 100px;
            background-color: brown;
            position: relative;
            z-index: 1000;
        }

        .c2 {
            height: 150px;
            width: 150px;
            background-color: blueviolet;
            position: relative;
            top: -100px;
            z-index: 998;
        }

    </style>
</head>
<body>
<div class="c1"></div>
<div class="c2"></div>
</body>
</html>

 

posted @ 2019-07-06 19:19  市丸银  阅读(152)  评论(0编辑  收藏  举报