爲什麼100%的寬度在此實現(其中類uk-width-1-1
被施加到網格容器的孩子的嵌套格)施加:爲什麼應用uk-width-1-1會影響uk-grid的子div而不是嵌套div的div?
<div uk-grid>
<!-- column 01 -->
<div>
<!-- this will be a row, stacked -->
<div class="uk-width-1-1 mine">Row 01</div>
<!-- this will be a row, stacked -->
<div class="mine">Row 02</div>
</div>
</div>
然而實現這樣的,當它被施加(其中類uk-width-1-1
是適用於網格容器的孩子):
<div uk-grid>
<!-- column 01 -->
<div class="uk-width-1-1">
<!-- this will be a row, stacked -->
<div class="mine">Row 01</div>
<!-- this will be a row, stacked -->
<div class="mine">Row 02</div>
</div>
</div>
我可以看到如何實現我想要的效果,但想知道的邏輯是什麼背後這樣我就可以更好地理解它。
jsFiddle顯示兩種實現是here。
編輯:
我可以複製只使用Flex樣式的行爲 - 所以我需要弄清楚爲什麼孩子DIV 100%和嵌套的div不能?
<!-- nested div is only the width of the content -->
<div style="display:flex; flex-wrap: wrap">
<div>
<div style="width:100%; background: red">Item 1</div>
<div style="width:100%; background: red">Item 2</div>
</div>
</div>
<!-- if applied to child div, is 100% width of parent -->
<div style="display:flex; flex-wrap: wrap">
<div style="width:100%">
<div style="background: red">Item 1</div>
<div style="background: red">Item 2</div>
</div>
</div>
<!-- if not using flex at all, nested divs are 100% width of parent -->
<div>
<div>
<div style="width:100%; background: red">Item 1</div>
<div style="width:100%; background: red">Item 2</div>
</div>
</div>
也許flex item
,這是在一個flex container
任何直接子格,默認情況下是它的內容的寬度,因此嵌套的div,如果給定的width: 100%
,如實地表示的100%的其直接父容器的寬度,而不是定義了display: flex
的頂級容器?
有東西在我的答案失蹤我可以添加到它已經接受? – LGSon