CSS定位问题
当然,我正在尝试用 HTML 构建一些东西。
然而,我在定位方面遇到了一些严重的问题!
我试图让网站中的元素居中,但如果不牺牲(以某种方式)控制(例如 z-index 和这些元素的宽度),我就无法做到这一点 - 在某些情况下,反之亦然。
理论上,我应该能够使某些东西居中,设置它的宽度,并设置它的 Z 索引。
有人可以帮忙吗?
I'm trying to, of course, build something in HTML.
However, I am running into some serious issues with positioning!
I'm trying to get elements in the website to be centered, but I cannot do that without sacrificing (somehow) controls such as z-index, and width on those elements -- In some cases, vice versa.
Theoretically, I should be able to make something be centered, set it's width, AND set it's Z index all at once.
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将某些内容居中,请将其边距设置为
auto
。要设置对象宽度,请设置它的width
;要设置对象的 z-index,请将其位置设置为relative
以保持其中心位置,并相应地设置它的 z-index。示例: http://jsfiddle.net/wDzkd/
To center something, set it's margins to
auto
. To set an objects width, set it'swidth
, to set an object's z-index, set it's position torelative
to maintain it's centreness, and set it's z-index accordingly.Example: http://jsfiddle.net/wDzkd/