实现一个div在浏览器水平居中_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:20:57
Original
1160 people have browsed it

第一种方法:

1 div {2  margin: 0 auto;3  width: 960px;4 }
Copy after login

第二种方法(兼容IE):

body { text-align: center; }  div {    margin: 0 auto;    width: 960px;  }
Copy after login

第三种方法(不推荐):

div {  position: relative;  left: 50%;  margin-left: -480px;  width: 960px;}
Copy after login

 

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!