1.先看要实现的效果
实际的效果图可以看到我的实现过程是先使用一个父级的div来定位水平垂直居中,然后再父级的div中定位出两个十字架的div。
看实现代码:
body{margin:0;padding:0} /*定位父级div水平垂直居中*/ .body_main{ width:200px; height: 300px; background-color: #3091E5; margin:-150px 0 0 -100px; top:50%; left:50%; position: absolute; } /*定位水平div垂直居中*/ .row_div{ width:200px; height: 50px; background-color:#88E500; position: absolute; top:50%; margin:-25px 0 0 0; } /*定位列div水平居中*/ .clou_div{ width:50px; height: 300px; background-color: #3c510c; left:50%; position: absolute; margin:0 0 0 -25px; }
横向的div
查看更多关于css定位练习“十字架“之水平垂直居中_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did108073