對齊兩個事業部盒
回答
<style>
.item {white-space: nowrap;display:inline; }
</style>
<fieldset>
<div class="item">
<input type="checkbox" id="a">
<label for="a">a</label>
</div>
<div class="item">
<input type="checkbox" id="b">
<label for="b">b</label>
</div>
<br/> //link break or anything you like
<div class="item">
<input type="checkbox" id="c">
<label for="c">c</label>
</div>
<div class="item">
<input type="checkbox" id="c">
<label for="c">D</label>
</div>
</fieldset>
這應該適用於你稍微輕微的變化,如果你覺得。 謝謝。
如果這只是一個固定的文件,不需要內容管理,我會使用列以方便使用。如果它需要內容管理和內容可能會改變,那麼我會去處理行。
HTML:
<html>
<div class="column one">
<div class="box A"></div>
<div class="box C"></div>
</div>
<div class="column two">
<div class="box B"></div>
<div class="box D"></div>
</div>
</html>
CSS:
div.column {
width:50%;
}
div.column.one {
float:left;
}
div.column.two {
float:right;
}
div.box {
width:40px;
height:40px;
}
在css中沒有第二列 – InTheWorldOfCodingApplications
我知道,它應該填充空格並且符合 - 浮動元素。現在你已經提到它了,我開始懷疑自己,無論哪種方式,第二個只需要應用一個浮動。 – InsomniaBass
完成,只需要我說的浮動。我錯過了';'在寬度之後,這讓我有點不安。 – InsomniaBass
一個可能的解決方案是將複選框標籤標籤內
<label for="cb1"><input id="cb1" name="cb1" type="checkbox" /> checkbox1 </label>
<label for="cb2"><input id="cb2" name="cb2" type="checkbox" /> checkbox2 </label>
<label for="cb3"><input id="cb3" name="cb3" type="checkbox" /> checkbox3 </label>
<label for="cb4"><input id="cb4" name="cb4" type="checkbox" /> checkbox4 </label>
和風格化它如下
label {
display:block;
width:50%;
*width:49%; /*for IE7 only*/
float:left;
}
label[for="cb3"] {
clear:left;
}
感謝利亞姆呼籲關注這個SO問題:Should I put input tag inside label tag?。
現在答案與屏幕閱讀器和IE7兼容。
- 1. 事業部垂直對齊
- 2. 對齊文本垂直的事業部
- 3. 事業部對齊和形狀
- 4. 正確地將兩個盒子對齊
- 5. 三個盒子不要對齊頂部
- 6. 對齊各個事業部在引導山坳底部1
- 7. Css右對齊兩個盒子一個在另一個之上
- 8. 柔性盒對齊頂部和對齊中心
- 9. 對齊一個盒子,在底部而不是頂部
- 10. 將兩個盒子對齊,其中一個盒子的位置是:fixed;
- 11. 對齊兩個div的,在一個盒子文本
- 12. 對齊兩個表的頂部
- 13. 在底部對齊兩個按鈕
- 14. 事業部對齊問題在Internet Explorer 9
- 15. 事業部,placeeholder,可自動調整寬度,內容和對齊
- 16. 將盒子對齊到CSS盒子
- 17. 對齊兩個DIV
- 18. 將diving中的3個盒子對齊
- 19. 齊平的CSS盒子對齊
- 20. h盒子對齊在gtk
- 21. DIV盒子不會對齊
- 22. 對齊盒Twitter的引導
- 23. 盒inline-block的不對齊
- 24. 文本將不會垂直對齊內部事業部無論什麼
- 25. 各事業部
- 26. 對齊兩個標籤的底部和頂部在垂直UIStackView
- 27. 水平對齊兩個DIV
- 28. 並排對齊兩個div
- 29. 對齊兩個div的左
- 30. 對齊兩個Javafx GridPane
你嘗試過什麼嗎? – Sachin
那麼這些A B C D是4格,其中每個部門包含「1複選框+ 1文字說明」? – Stano
你可以把每個盒子放在div中,會有兩種div,一個是'float:left',另一個是'float:right',你給它們一些寬度,就是這樣! –