阅读背景:

flex布局 响应式布局 过渡 动画

来源:互联网 

Z-index

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>z-index</title>
    <style type="text/css">
        .box{
            <!-- 辅助子级进行绝对定位 -->
            position:relative;
            width:400px;
            height:400px;
            background-color:red;
            margin:0 auto;
            position:relative;
        }
        .d1,.d2,.d3{
            width:200px;
            height:200px;
            position:absolute;
        }
        .d1{
            background-color:orange;
        }
        .d2{
            background-color:blue;
            top:calc(50% - 100px);
            left:calc(50% - 100px);
        }
        .d3{
            background-color:black;
            right: 0;
            bottom:0;
        }
        <!-- 脱离文档流的标签,具有z-index属性,可以用来控制显示层次的优先级,值为任意正整数 -->
        .d2{
            z-index:1;
        }
    </style>
</head>
<body>
    <!-- 需求1:d1,d2,d3均为box的一半大小 -->
    <!-- 需求2:d1左上角,d2居中,d3右下角 -->
    <!-- 需求3:d2区域在最上方(会覆盖d1,d3重叠部分) -->
    <div class="box">
        <div class="d1"></div>
        <div class="d2"></div>
        <div class="d3"></div>
    </div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
   



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: