編輯:這是一個JFiddle它看起來像目前基於人們的幫助,但仍需要一點點的工作。需要幫助對齊CSS中的12個項目
我有12個div和一個容器div。容器div中的12個div組成6個文本和6個相應的輸入字段。
我想它看起來就像這樣......
[Text1 Input Item1 Text2 Input Item2 Text3 Input Item3]
[Text4 Input Item4 Text5 Input Item5 Text6 Input Item6]
什麼是CSS格式的最佳方式?我嘗試了它,它只是遍佈整個地方,盒子錯位,放錯了行。有人可以幫忙嗎?
<div class="container">
<div class="text1"></div>
<div class="InputItem1"></div>
<div class="text2"></div>
<div class="InputItem2"></div>
<div class="text3"></div>
<div class="InputItem3"></div>
<div class="text4"></div>
<div class="InputItem4"></div>
<div class="text5"></div>
<div class="InputItem5"></div>
<div class="text6"></div>
<div class="InputItem6"></div>
</div>
CSS代碼:
.container{width:100%;}
.text1{width:15%;float:left}
.InputItem1{width:15%;float:left}
.text2{width:15%;float:center}
.InputItem2{width:15%;float:center}
.text3{width:15%;float:right}
.InputItem3{width:15%;float:right}
.text4{width:15%;float:left}
.InputItem4{width:15%;float:left}
.text5{width:15%;float:center}
.InputItem5{width:15%;float:center}
.text6{width:15%;float:right}
.InputItem6{width:15%;float:right}
如果你想要的確如此,只需使用'tables';他們仍然用於表格數據 – Phil
我知道這是老式的,但表怎麼樣? – Horen
這是我第一次使用CSS,所以我從來沒有使用表格,我會檢查出來。 – Hoser