我有一个固定宽度的容器 div。我希望其中一个子元素与浏览器窗口一样宽。我会将子元素从父容器中取出,但它会破坏功能。我试过这个:
.parent { width: 960px; position: relative; left: 50%; margin-left: -480px; }
.child { position: absolute; left: 0; right: 0; width: 100%; }
对此:
<body>
<div class="parent">
<div class="other">This div's positioning is absolute but dependent on the parent element's relative positioning</div>
<div class="child>This div wants to be centered and as wide as the browser window</div>
</div>
</body>
但这不起作用。有什么我可以做的吗?