I presume the answer to this question is really simple but i am stumped.
I am trying to get a website positioned in the center of the screen like the Guardian website - http://www.guardian.co.uk/ 。我认为我使用左右边框是正确的,但是这使得定位页脚变得困难。
查看了 Guardian 网站并使用了 firefox 检查元素功能,看来他们在屏幕的左侧和右侧都没有使用 div。事实上,容器似乎只是在屏幕的中间。
所以我想我的问题是。你如何定位这样的容器?
最佳答案
.container {
/* remember to set a width */
margin-right: auto;
margin-left: auto;
}
margin: 0 auto;
关于html - 如何在屏幕中间放置一个容器?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14402038/