2015-11-04 30 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