【问题标题】:Getting a div out of another div从另一个 div 中获取一个 div
【发布时间】:2015-01-07 20:05:32
【问题描述】:

我在容器 div 和内容 div 中有一个 div 'offers',容器 div 的宽度为 1200px,内容 div 的宽度为 100%,填充为 1em。我希望 'offers' div 从 div 中出来并使用屏幕的整个宽度,我尝试了绝对位置、z-index 和 100% 宽度,但这不起作用。有人给我答案吗?

【问题讨论】:

  • 向我们展示您的代码或制作小提琴演示
  • 重新设计你的页面,不要尝试用非 css 来做。
  • 当你说“不工作”时,你期待什么,你实际得到了什么?我们需要 HTML 和 CSS!
  • 感谢下面的评论,它正在工作

标签: css


【解决方案1】:

如果没有您的代码,我无法给出完整的答案,但请尝试使用绝对 div 的 left: 0; right 0; 而不是 width

【讨论】:

  • 非常感谢您完成了这项工作。
【解决方案2】:

只需关闭容器,获得 100% div,然后打开一个新容器。

“容器”只是一个指南而非规则。

Codepen Demo

* {
 margin:0;
 padding:0;
 }

.container {
  max-width: 1200px;
  margin:0 auto;
  height: 200px;
  /* for visual reference */
  background-color: #bada55;
}
.full {
  height: 200px;
  /* for visual reference */
  background-color: #663399;
}
<div class="container"></div>
<div class="full"></div>
<div class="container"></div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-04
    • 2020-01-24
    • 1970-01-01
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    相关资源
    最近更新 更多