如何設置三個水平像這樣排列? 左側寬度:150px,右側寬度:150px,中心一個寬度是其餘像素,中心一個最小寬度將是800px。所有的div都需要一個位置:相對的。 謝謝。css-how to set three parallel DIV?
回答
在這裏,我們走了,HTML是如下:
<div id="wrap">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
<div class="clearBoth"></div>
</div>
,現在下面的CSS:
#wrap {
width: auto;
position: relative;
}
.left, .right {
width: 150px; //or use 30%
float: left;
}
.center {
float: left;
min-width: 800px; //or use 60%
width: auto;
position: relative;
}
.clearBoth {
clear: both;
}
感謝Toro,你的代碼更精彩。 – 2010-11-09 23:12:37
對不起,我是一個新人,我不能投票'這個答案對你有幫助'。 – 2010-11-09 23:14:27
別急!重要的是這項工作;) – 2010-11-10 10:12:40
如果要定義固定的最大寬度,請使用換行。
.wrap {
overflow:hidden;
width:1200px; /* Optional */
}
.left {
float:left;
width:150px;
}
.middle {
float:left;
min-width:800px;
}
.right {
float:left;
width:150px;
}
<div class="wrap">
<div class="left">Left</div>
<div class="middle">Middle</div>
<div class="right">Right</div>
</div>
不要忘記寬度:800px; .middle {} – 2010-11-09 17:19:50
啊,對了,忘了他提到了最小寬度。在那裏補充說。 – 2010-11-09 17:21:04
謝謝,在這種情況下,包裝允許設置百分比? .wrap { overflow:hidden; 寬度:100%;/*可選*/ } – 2010-11-09 17:38:34
- 1. THREE = require'./three'
- 2. bootstrap set margin left to .container
- 3. from PIC18f4550 to serial in parallel out latch
- 4. git push --set-upstream vs --set-upstream-to
- 5. set Context.User.identity:name to JavaScript變量
- 6. Javascript set getter to class本身
- 7. Set Title to TableViewController - 初學者
- 8. directionallight three js
- 9. jquery set previous div class
- 10. THREE Light 360度
- 11. THREE JS computeVertexNormals()性能
- 12. jQuery val to div
- 13. Tab to overlayed div
- 14. Javascript scroll to div
- 15. 速記Powershell的`的ForEach -Parallel`
- 16. Retriving Values form databse to set Item Title in menu.xml
- 17. set/change value to drop down using jquery
- 18. set div 50%height with overflow auto
- 19. Parallel EntityFramework
- 20. PARALLEL submakes
- 21. Parent div,height not set,over-sizes height by several pixels to fit child img element height?爲什麼?
- 22. Smooth div div id to div id not working?
- 23. jquery resizable snap to div
- 24. Onclick slide to current div
- 25. fit div to browser page
- 26. Model-View-Presenter和Three-Tier?
- 27. Parallel ForEach和ConcurrentBag
- 28. OpenCL Parallel Dispatch
- 29. Parallel ForEach on DataTable
- 30. 使用PARALLEL make
你有什麼要求,使用div的,一般DIVS建議使用。但是,如果你的情況很簡單,表格可能會快速且容易地創建三列或四列。 – kobe 2010-11-09 17:24:08
相關:http://stackoverflow.com/questions/4116085/how-come-these-divs-will-not-display-on-the-same-line/4116103#4116103 – DaiYoukai 2010-11-09 19:24:28