将DIV中心置于页面中心,而不考虑屏幕大小 [英] Center a DIV to the center of page regardless of screen size

查看:188
本文介绍了将DIV中心置于页面中心,而不考虑屏幕大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将以下div容器置于网站中心位置,而不考虑屏幕大小。

I want to center the below div container to that the site appears in the center of the page, regardless of the screen size.

http://penarthpc.com/~droneboy/

推荐答案

解决这个问题的方法是使用在CSS中为 margin 自动,并为DIV本身提供一些宽度:

The solution to this problem is using auto for margin in the CSS AND providing some width to the DIV itself:

div.centered {
margin-left:auto;
margin-right:auto;
width:80%;
}

这篇关于将DIV中心置于页面中心,而不考虑屏幕大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆