佈局 - z-index

powerx_yc發表於2018-08-08
<style type="text/css">
        #left{
            top: 0;
            bottom: 0;
            position: fixed;
            width: 200px;
            margin-top: 60px;
            overflow-y:auto;
            z-index: 2;
        }
        #right{
            top: 0;
            bottom: 0;
            position: fixed;
            margin-top: 60px;
            padding-left: 200px;
            overflow-y:auto;
            width: 100%;
            z-index: 1;
        }
        h1{
            margin: 0px;
        }
    </style>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div style="background-color: gray;width:200px;position: absolute;top: 0;bottom: 0;left: 0;z-index: 1">
        <div style="background-color:red;width: 210px;height: 50px;position: absolute;left: 0;right: 0;top: 0;bottom: 0;margin: auto;z-index: 3"></div>
        <div style="background-color:black;width: 400px;height: 600px;position: absolute;left: 0;right: 0;top: 0;bottom: 0;margin: auto;z-index: 2;margin-left: 190px;">
        </div>
    </div>
</body>
</html>
4537021-0f1e4f47857a7529.png

4537021-51304f98d97f62a1.png

相關文章