下面的代码,已经用了margin-left:auto,为什么还是没法居中?_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:24:57
Original
1548 people have browsed it


回复讨论(解决方案)

我想设置DIV在TOP上是不变的,不会因为前面的DIV高度增加而下移,所以设置了position: absolute;top:120px;

但这样的话,自动居中又怎么办?

使用过 position:absolute;的话   居中就要用 top:50%; left:50%;来进行定位,
这个还要看你的元素所在文档流中的位置来看,呵呵不过 一般 Left:50% 就能居中了 具体数值你自己调下

有宽度加auto就居中了,不用绝对定位

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!