css那些事儿2 经典两列布局
生活随笔
收集整理的這篇文章主要介紹了
css那些事儿2 经典两列布局
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title></title>
5 <link rel="stylesheet" type="text/css" href="css/main.css">
6 </head>
7 <body>
8 <div id="header">頭部</div>
9 <div id="container">
10 <div class="mainBox">
11 內容區域
12 <p>我說情愛的請大賽撒謊和大嫂多少</p>
13 <p>hsdaufhsalfsa</p>
14 <p>shhsaldhsakl</p>
15 <p>我說情愛的請大賽撒謊和大嫂多少</p>
16 <p>hsdaufhsalfsa</p>
17 <p>shhsaldhsakl</p>
18 <p>我說情愛的請大賽撒謊和大嫂多少</p>
19 <p>hsdaufhsalfsa</p>
20 <p>shhsaldhsakl</p>
21 <p>我說情愛的請大賽撒謊和大嫂多少</p>
22 <p>hsdaufhsalfsa</p>
23 <p>shhsaldhsakl</p>
24 <p>我說情愛的請大賽撒謊和大嫂多少</p>
25 <p>hsdaufhsalfsa</p>
26 </div>
27 <div class="sideBox">
28 側邊欄
29 <span>把手</span>
30 </div>
31 </div>
32 <div id="footer">底部</div>
33 </body>
34 </html> 1 body{
2 padding: 0px;
3 margin: 0px;
4 }
5
6 #header,#footer{
7 height: 50px;
8 background-color: #e9e9e9;
9
10 }
11
12 #container{
13 position: relative;
14 overflow: hidden;
15 margin: 10px 0px;
16 }
17
18 #container:after{
19 display: block;
20 content: "";
21 line-height: 0px;
22 font-size: 0px;
23 clear: both;
24 visibility: hidden;
25 }
26
27 .mainBox{
28 margin-left: 320px;
29 background-color: green;
30 width: auto;
31 color: white;
32 }
33
34 .sideBox{
35 width: 300px;
36 height: 500px;
37 position: absolute;
38 left: 0px;
39 top: 0px;
40 background: #234567;
41 }
42
43 .sideBox span{
44 background: red;
45 color: white;
46 right: 0px;
47 position: absolute;
48 top: 50%;
49 width: 30px;
50 height: 50px;
51 text-align: center;
52 }
?
要想兩列等高一般采用js進行計算設置,如果采用css則可以使用背景填充辦法,或者背景色填充辦法,但都不是太好
轉載于:https://www.cnblogs.com/rjjs/p/6498575.html
總結
以上是生活随笔為你收集整理的css那些事儿2 经典两列布局的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Null和Undefined类型
- 下一篇: /*去hover动画效果*/