2015-11-04 34 views
1

我有时会发现自己希望为内容位于标准容器内的网站的一部分放置全宽背景。例如:为什么不应该引导容器嵌套?

<div class="container"> 
    <!--here is a section of awesome things that doesn't need a full width background --> 
</div> 

<div class="container-fluid" style="background-color: purple"> 
    <div class="container> 
    <p>This is an average paragraph</p> 
    </div> 
</div> 

Bootstrap says NOT to nest containers

Note that, due to padding and more, neither container is nestable. 

我知道我可以在一个类中创建一个不同的div,但我不知道嵌套容器的具体危险可能是什么?

+0

可以使用倍数,但没有嵌套。而不考虑风险。风险在于bootstrap中的一些内容依赖于相对选择器。这些可能会在嵌套的情况下破裂。我之前已经遇到过嵌套各种元素。 – Derple

回答

1

抱歉想不出在评论解释,这里就是我跟随

<div class="container-fluid" style="background-color: purple"> 
    <div clas=row> 
<!--here is a section of awesome things that doesn't need a full width background --> 
    </div> 
</div> 
<div class="container-fluid" style="background-color: purple"> 
    <div clas=row> 
     <div class="container> 
       <div class=row> 
       <p>This is an average paragraph</p> 
       </div> 
     </div> 
    </div> 
</div> 
+0

有趣的o.0很好。 – Derple