本章节分享一段代码实例,它演示了如何让div实现全屏垂直水平居中和指定元素的内容垂直水平居中。
代码实例如下:
蚂蚁部落 #main{ position:absolute; background-color: blue; width:400px; height:200px; left:50%; top:50%; margin-left:-200px; margin-top:-100px; border:1px solid #00F;}#content{ position:absolute; background-color:yellow; width:200px; height:100px; left:50%; top:50%; margin-left:-100px; margin-top:-50px;}
查看更多关于div垂直水平居中代码实例_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did110569