margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0
bottom: 0;
width: 100px;
height: 100px;
border:1px solid red;
}
将产生一个div, width: 100px; height: 100px; 外边框 1px 红色实线 ;
div居于屏幕中间,对于居于中间这点,我无法理解,为何下面的做法不可以?
div {
margin: auto;
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
border:1px solid red;
}
回复讨论(解决方案)
问题1
top: 0;
left: 0;
为何不可以代替
top: 0;
left: 0;
right: 0
bottom: 0;
问题2
margin:auto为何不可以代替
margin: auto;
top: 0;
left: 0;
right: 0
bottom: 0;
div { margin: auto; position: absolute; right: 0; bottom: 0; top: 0; left: 0; width: 100px; height: 100px; border:1px solid red; }
查看更多关于div居中的问题_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did114274