DIV在另一个DIV里面垂直居中,水平居中

Posted 洛阳之晨,譬如临安初雨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DIV在另一个DIV里面垂直居中,水平居中相关的知识,希望对你有一定的参考价值。

html

 <div class="parent">
        <div class="children">
            <div class="close">
                <img src="image/ico/icon-close.png" />
            </div>
        </div>
    </div>

CSS:

   <style type="text/css">
        .parent {
            width:800px;
            height:800px;
            background:#286921;
             position:relative;
        }
        .children {
            border:3px #fff solid;
            width:80px;
            height:80px;
            margin:auto;
            top: 0; left: 0; bottom: 0; right: 0; 
            position: absolute;  
        }
        .close {

        }
    </style>

 

以上是关于DIV在另一个DIV里面垂直居中,水平居中的主要内容,如果未能解决你的问题,请参考以下文章

如何让DIV里面的DIV水平垂直居中

CSS一个盒子在另一个盒子水平垂直居中

前端面试CSS系列——DIV垂直水平居中

总结div里面水平垂直居中的实现方法

div+css 怎么让一个小div在另一个大div里面 垂直居中

怎么让一个不定宽高的div水平居中,垂直水平居中