我想創建在asp.net頁面,我需要的頁面分成3列頁面佈局的各個不同的充寬度(20%,60%,20%),每列的高度應延伸到最大頁面高度。
我不想使用position:absolute
和使用左,上屬性來定位div標籤,因爲有些人說,使用position:absolute
是不好的,它會創造超過其他瀏覽器的問題。 請在這方面向我提供幫助,對此有不同的解決方案。 :)3柱採用div和css
0
A
回答
0
下面是HTML
<div class="width20">
Div with width 20%
</div>
<div class="width60">
Div with width 60%
</div>
<div class="width20">
Div with width 20%
</div>
這裏是CSS
body {
margin:0;
padding:0;
}
.width20 {
float:left;
width:20%;
background:grey;
height:100vh;
}
.width60 {
float:left;
width:60%;
background:orange;
height:100vh;
}
0
HTML
<div class="container">
<div class="grid_1">
<p>20%</p>
</div>
<div class="grid_2">
<p>60%</p>
</div>
<div class="grid_1">
<p>20%</p>
</div>
<div class="clear"> </div>
</div>
CSS
.container {
background-color: #333333;
width: 100%;
}
.grid_1{
display: inline;
float: left;
width: 20%;
position: relative;
}
.grid_2{
display: inline;
float: left;
width: 60%;
position: relative;
}
p {
border: 1px solid #333333;
padding: 10px;
background-color: #FFFFFF;
}
.clear {
clear: both;
display: block;
height: 0;
overflow: hidden;
visibility: hidden;
width: 0;
}
0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<style>
html,body{
width: 100%;
height: 100%;
margin: 0%;
}
#one{
width: 20%;
height: 100%;
float: left;
background-color: red;
}
#two{
width: 60%;
height: 100%;
float: left;
background-color: green;
}
#three{
width: 20%;
height: 100%;
float: left;
background-color: blue;
}
</style>
</head>
<body>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
</body>
0
與浮動使用div標籤離開;它會幫助你。
HTML
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>
CSS
body{
height:100%;
min-height:100%;
width:100%;
position:absolute;
}
.first{
background-color:red;
width:20%;
height:100%;
float:left;
position:relative;
}
.second{
background-color:yellow;
width:60%;
height:100%;
float:left;
position:relative;
}
.third{
background-color:green;
width:20%;
height:100%;
float:left;
position:relative;
}
0
你可以使用這樣的事情:JSFiddle
HTML
<div id="content">
<div class="side-bar">Content</div>
<div class="main-content">main Content</div>
<div class="side-bar">Content</div>
</div>
CSS:
#content {
width:100% height:100%;
position:relative;
display:table;
}
.main-content {
background:#ccc;
height:100%;
width:60%;
display:table-cell;
}
.side-bar {
width:20%;
background:#eee;
height:100%;
vertical-align:top;
display:table-cell;
}
希望這有助於
相關問題
- 1. CSS:3柱高100%
- 2. 3列div css
- 3. CSS 3柱流體固定流體
- 4. (HTML + CSS)頁面佈局採用div和浮動
- 5. 採用div類
- 6. 不採取CSS屬性值DIV的jQuery
- 7. 使用DIV和CSS
- 8. 支柱佈局多采用reqCode
- 9. CSS 3柱流體佈局問題,第3列太寬
- 10. CSS - 3個div的花車
- 11. Div as Radio HTML5 CSS Bootstrap 3
- 12. 對齊3 div的CSS
- 13. CSS柱結構
- 14. CSS - 流體柱
- 15. CSS - 交換柱
- 16. 全高CSS柱
- 17. Div採用屏幕寬度和高度
- 18. 5柱 - 3固定寬度柱和2流體
- 19. Rails 3和CSS
- 20. CSS和Jquery使用一個DIV創建3列
- 21. html和css for div div和div左右
- 22. CSS,DIV和H1
- 23. 表DIV和CSS
- 24. CSS問題:固定柱+自動柱內
- 25. 用css和div模擬rowspan?
- 26. 用CSS連接「div」和「p」
- 27. 使用HTML的div和CSS
- 28. CSS液柱寬度
- 29. 帶固定和液柱的CSS佈局
- 30. HTML柱造型和邊境的CSS
你試圖去創造你的自我? – SpiderCode