Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道我到底做了什么,但我的内容 div 不再在我的屏幕中间对齐。这是我的代码:
#divwrapper { width: 1100px; margin: 0 auto; }
我还在其中放置了各种其他 div,用于标题、正文等,position: absolute;以及坐标。
position: absolute;
我在网上搜索了整个网络,似乎这就是我应该让它工作的方式......但它不起作用。我难住了。
你的#divwrapper 很好。但是,您使用 绝对定位了其中的所有元素left: 50px,这使得 #divwrapper 无关紧要:您的元素现在将从页面左侧浮动 50px。
left: 50px
您是否还打算添加position: relative;到您的#divwrapper 的 CSS 中?绝对定位的元素根据它们的第一个定位祖先组织自己:如果那是#divwrapper,添加该行将使您的布局元素相对于#divwrapper 定位自己。否则,他们将相对于页面定位自己。
position: relative;