带有position时的居中,包括fixed、relative、absolute

2017-01-04 19:27:10来源:CSDN作者:wangweiscsdn人点击

第七城市

啥都不说上代码:

<!DOCTYPE html><html><head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <title>居中</title>    <link rel="stylesheet" href="">    <style>    .d1 {        position: fixed;        bottom: 0;        left: 0;        width: 100%;        height: 300px;        background-color: green;            }        .d2 {        position: relative;        width: 1000px;        height: 200px;        bottom: 50px;        margin: 0 auto;        background-color: grey;    }        a {        display: block;        position: absolute;        bottom: 156px;        right: 0px;        width: 50px;        height: 50px;        cursor: pointer;        font: normal 50px Simsun;        color: #fff;    }    </style></head><body>    <div class="d1">        <div class="d2">            <a>×</a>        </div>    </div></body></html>










第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台