如何設置三個水平像這樣排列? 左側寬度: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. set javascript div id to increasing var
- 2. THREE = require'./three'
- 3. bootstrap set margin left to .container
- 4. Lwuit-set ticker to labels
- 5. git set upstream to origin
- 6. from PIC18f4550 to serial in parallel out latch
- 7. git push --set-upstream vs --set-upstream-to
- 8. Java Set <Set<String>> to String [] []
- 9. SSRS 2008 go to url getting set to target = _top
- 10. Set Title to TableViewController - 初學者
- 11. set Context.User.identity:name to JavaScript變量
- 12. Javascript set getter to class本身
- 13. directionallight three js
- 14. 隱藏System.out.println(three);
- 15. THREE Light 360度
- 16. THREE JS RawShaderMaterial
- 17. jquery set previous div class
- 18. THREE JS computeVertexNormals()性能
- 19. jQuery val to div
- 20. Javascript scroll to div
- 21. Javascript variable to div
- 22. HTML:Table to Div
- 23. Tab to overlayed div
- 24. HTML Div to CSS?
- 25. Parallel Dijkstra
- 26. 速記Powershell的`的ForEach -Parallel`
- 27. THREE JS動畫片
- 28. jqPlot plot object to div div
- 29. Retriving Values form databse to set Item Title in menu.xml
- 30. iOS Core Location Set Pin to user location in viewDidLoad
你有什麼要求,使用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