css - 全宽行和周围的容器

标签 css zurb-foundation

我使用的是最新版本的 Zurb Foundation。我想使用全宽布局并使用非 Canvas 元素。

所以我有一个 demo突出显示问题,但是我想要全宽行,但仍然能够用全宽背景色包围该行。 (例如 http://foundation.zurb.com/ )就像英雄 block 。

为简单起见,这是有问题的代码:

HTML

 <section class="content-block">
      <div class="row full-page">
          <div class="large-12 columns">
              <h3>We&rsquo;re stoked you want to try Foundation! </h3>
              <p>To get going, this file (index.html) includes some basic styles you can modify, play around with, or totally destroy to get going.</p>
              <p>Once you've exhausted the fun in this document, you should check out:</p>             
          </div>
        </div>
        </section>

CSS:

.full-page {
   min-width: 100%;
   margin-left: auto;
   margin-right: auto;
   max-width: initial;
}


.content-block {
    background:#000;
}

我希望页面的整个宽度为黑色。

最佳答案

发生这种情况是因为在 .columns 元素上他们使用了 float。这使元素脱离了流,因此不再根据其内容调整大小(因为内容不在同一流中并且只是溢出)。

要强制元素保持在同一流中,您可以使用:

.full-page {
    min-width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-width: initial;
    overflow: hidden;
}

jsFiddle

关于css - 全宽行和周围的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20219998/

相关文章:

Jquery 元素定位等

javascript - 替代css3而不是选择器

javascript - 最小数值为 125 的正则表达式?

html - 最佳基础html嵌套实践

css - Zurb Foundation "th" block 网格内的缩略图无响应

jquery - 在移动设备上查看时,Bootstrap 会更改 div 上的类

javascript - 页面加载时,如何让6个函数相互执行?

javascript - 为什么 Foundation 6 的 Accordion 滚动到页面顶部而不是展开选定的选项卡?

javascript - Zurb foundation for sites v6 选项卡不起作用

c# - CSS 影响所有页面,但我只想将它用于一个页面