简体   繁体   English

流体容器位于流体现场的静态容器中

[英]Fluid container in a static container on a fluid site

i am trying to achieve a specific layout in SUSY but i am kinda struggling. 我试图在SUSY中实现特定的布局,但我有点挣扎。

I want to have a site that is basically fluid full width when it comes to header or footer, the main content should be in a container that is restricted to a specific width, but it should be also possible to have full width elements( like backgrounds) within the static container ( they would break out of their static container but having their inner content still aligned to the static container ). 我希望网站的页眉或页脚基本上是全宽的,主要内容应放在限制为特定宽度的容器中,但也应该有全宽元素(例如背景) )放在静态容器中(它们会脱离其静态容器,但其内部内容仍与静态容器对齐)。

I archived it using 2 different container maps, one restricted and one fluid. 我使用2个不同的容器图(一个受限的和一个流体的)将其归档。 that works so far. 到目前为止有效。

The Problem i run into is that i cant align the content of the fluid width element to the static content, if push the element, the wrong container will be pushed if its in the right container map. 我遇到的问题是我无法将流体宽度元素的内容与静态内容对齐,如果推动该元素,则如果在正确的容器图中将错误的容器推入。 as u can see in the codepen. 如您在Codepen中所见。

I tried to work it out with stacking the fluid container in the static and then back to static...what kinda didn't work as expected. 我试图通过将流体容器堆叠在静态容器中,然后又恢复为静态容器来解决这个问题……这并没有按预期进行。 I made a workaround using : 我使用了一种解决方法:

.o-fullwidth {
  left: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  position: relative;
  right: 50%;
  width: 100vw;
}

to force the element out of its static container. 将元素从其静态容器中推出。

Is my whole approach with two containers completely wrong? 我使用两个容器的整个方法是否完全错误? Is there a much better and easier way to have all the content (text etc) aligned with the static container but the background header and fluid element always fully stretched? 有没有一种更好,更轻松的方法来使所有内容(文本等)与静态容器对齐,但是背景标题和流体元素始终始终被拉伸?

I hope it makes sense...thanks a lot 我希望这很有道理...非常感谢

http://codepen.io/HendrikEng/pen/qrqdaP?editors=0100 http://codepen.io/HendrikEng/pen/qrqdaP?editors=0100

1st of all, your code looks complicated, doesn't it? 首先,您的代码看起来很复杂,不是吗? :) anything comlicated probably isn't a good solution, but kudos for trying it out! :)复杂的事情可能都不是一个好的解决方案,但是尝试它的荣誉! (I can see what you're doing, since I've done it before) (我可以看到您在做什么,因为我之前已经做过)

To point you in the right direction, consider using suay as a second level element, especially within your main area. 为了使您指向正确的方向,请考虑使用suay作为第二层元素,尤其是在您的主要区域内。 Here's an example of the possible HTML: 这是可能的HTML的示例:

<div class="full-width-bg"> 
    <div class="static-wrap"> 
        <!-- other elements in here --> 
    </div> 
</div> 

This way, you don't have to worry about overflowing background. 这样,您不必担心背景溢出。 Just apply a style/class to the outer div and you're good to go! 只需将样式/类应用于外部div,就可以了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM