2016-10-13 23 views
0

我使用flexbox,但我不知道項目拉伸。 我想獲得這樣的結果:我不知道爲什麼Flexbox項目拉伸

enter image description here

內容項目是合理的,當內容的空白結束他們包裹。就像這樣:

enter image description here

項目是DIV包含標籤和輸入元素。所以我希望整個潛水包裝和標籤不會被輸入分開。

這裏的HTML:

<tr class="form_boxes"> 
    <td colspan="3"> 
     <div class=""> 
      <span class="">NPA</span> 
      <input type="text" ng-model="np.npa" maxlength="5" class="char_5" /> 
     </div> 
     <div class=""> 
      <span>NXX</span> 
      <input type="text" ng-model="np.nxx" /> 
     </div> 
     <div class=""> 
      <span>ISO</span> 
      <input type="text" ng-model="np.iso" maxlength="5" class="char_5" /> 
     </div> 
     <div class=""> 
      <span>Descrizione</span> 
      <input type="text" ng-model="np.descrizione" /> 
     </div> 
     <div class=""> 
      <span>Location</span> 
      <input type="text" ng-model="np.location" /> 
     </div> 
     <div class=""> 
      <span>Root</span> 
      <input type="text" ng-model="np.root" /> 
     </div> 
     <div class=""> 
      <span>Billing ID</span> 
      <input type="text" ng-model="np.billingId" /> 
     </div> 
     <div class=""> 
      <span class="no-wrap">Ultimo aggiornamento: {{ np.ultimoUpdate }}</span> 
     </div> 
    </td> 
</tr> 

,這裏的CSS:

#internal_content .form_boxes { 
    width:500px; 
    display: flex; 
    flex-direction: row; 
    flex-wrap: nowrap; 
    justify-content: space-between; 
    align-items: baseline; 
    align-content: flex-start; 

    } 

#internal_content .form_boxes td { 
    width: 100%; 
} 

我也想去掉TR的固定大小... 這是結果,我獲得:

enter image description here

正如你所看到的,TR大小沒關係......和TD的大小如此(請相信我)。問題是DIV也伸展,但我不知道爲什麼!

enter image description here

任何人都可以幫助我達到我的目的嗎?

UPDATE

有了您的解決方案,現在我得到這樣的:

enter image description here

而且最後一行是有道理的......應該是這樣我張貼,而不是第一個圖像..我必須創建一個新的父級柔性盒嗎?

+1

應用'顯示:flex'到'td'代替 –

+1

如果你要使用Flexbox,就真的沒有必要使用一個表呢! –

+0

我更新了問題,是的...我刪除了表格! – Ciccio

回答

1

您使用了div的父母你的Flexbox,就使TD,你的類應該是TD元素上這樣的div受到影響

#internal_content .form_boxes td { 
    width:500px; 
    display: flex; 
    flex-direction: row; 
    flex-wrap: nowrap; 
    justify-content: space-between; 
    align-items: baseline; 
    align-content: flex-start; 
} 

,並刪除應該這樣做

寬度

此外divs伸展,因爲它們是塊元素和塊元素默認情況下始終具有全寬,除非您另行聲明

並且這也是問題解決方案的一部分

Flex-box: Align last row to grid

+0

幾乎我想要的...我更新了問題 – Ciccio

+1

@Ciccio是否有寬度爲500px的寬度?因爲我認爲它沒有空間讓它適合所有它在兩行 – souptical

+0

我刪除了寬度:500px ...但是,問題不是行數,但拉斯線也是合理的..我想它停在左邊......我不知道我是否解釋得很好..我的意思是「ultimo aggiornamento」,應該靠近計費編號的tectbox ......不在行尾 – Ciccio

相關問題