且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将项目放在页面的死点中心

更新时间:2023-11-20 12:25:52

根据指定的宽度和高度将div推到顶部和左侧.

Push the div to top and left based on the width and height specified.

CSS

 body{ background-color: #000;}
    div{
        background-color: #000;
        width:800px; 
        height: 200px; line-height: 200px;
        position: absolute;
        top: 50%; margin-top:-100px;
        left: 50%; margin-left:-400px;
        font-weight: bold;
        font-size: 100px;
        text-transform: uppercase;
        color: #ccc; text-align:center
    }​

演示

DEMO