在隐藏溢出的包装中心div [英] Centre div inside wrapper with overflow hidden

查看:87
本文介绍了在隐藏溢出的包装中心div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将固定宽度的包装div(包装器)放在另一个div(body)中,如下所示。

I wish to centre a wrapper div of fixed width (wrapper) inside another div (body) as you can see below.

line代表页面/浏览器窗口的中心,正如你所看到的,它的正文和包装中心都位于页面中间。

The line represents the centre of the page/browser window, and as you can see, it both the body and the centre of the wrapper are centred in the middle of the page.

有没有一种方法可以使用纯CSS和HTML来完成这项工作?

Is there a way to accomplish this using pure CSS and HTML?

预先感谢。

Thanks in advance.

推荐答案

有人打算为这个常见问题撰写简短的描述性 How To http://www.wpdfd.com/editorial/thebox/deadcentre4.html

Someone bothered to write a short and descriptive How To to this common issue: http://www.wpdfd.com/editorial/thebox/deadcentre4.html

你有两件东西在那里,所以你需要应用这种技术两次,但你不能真正地将body元素居中,所以你需要添加另一个容器而不是body。

You have two items to position in there, so you'll need apply the technique twice, but you can't really center the body element with this so you'll need to add another container instead of the body.

玩得开心!

这篇关于在隐藏溢出的包装中心div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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