亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

如何用CSS進行網頁布局

江老實 Web前端工程師
難度初級
時長22分
學習人數
綜合評分9.60
1991人評價 查看評價
9.8 內容實用
9.6 簡潔易懂
9.4 邏輯清晰
.top{width:100%;height:100px;margin:0;background:#ccc;}
.main{width:100%;height:500px;background:red;}
.left{width:200px;height:500px;float:left;background:blue;}
.right{margin-left:210px;width:100%;height:500px;background:green;position:absolute}
.foot{width:100%;height:150px;background:#F90}
上節視頻,定左右絕對,定左右上0;中間只設高度,不設寬,six,six,six
.left{ width:200px; height:500px; background:blue; }
.right{ height:500px; background:#9C9;width:100%;margin-left:220px;position:absolute}
為了兼容ie6,左右不用float;右側加絕對定位加寬度自適應即可
.left{width:200px;height:500px;background-color:blue; float:left;}
.right{height:500px;background-color:green;width:100%;margin-left:210px; position:absolute;}
因為right先加載,所以right用絕對定位position:absolute,left用float浮動;
.top{width:100%;background:#ccc;height:100px;}

.main{width:100%;background:red;height:500px;}

.left{width:200px;background:blue;height:500px;float:left;}

.right{background:#9BCD9B;height:500px;float:right;width:calc(100% - 210px);}

.foot{width:100%;background:#FF7F00;}
.top{height:100px;background:#ccc;}
.main{background:#f00;height:600px;position:relative;overflow:hidden;}父元素定位,overflow隱藏超出的部分
.left{height:600px;width:200px;background:#00f}
.right{height:600px;width:100%;position:absolute;background:#9a9;margin-left:210px;}
.foot{height:100px;background:#aa0;}
.footer{width:960px;height:50px;background:#9F9;margin:600px auto 0 auto;}
0換成auto就能居中了
.top{height:100px;background:#cccccc;}
.main{height:600px;background:#fa0002;}
.left{height:600px;width:33%;background:#0000fe;float:left;}
.right{height:600px;width:65%;background:#9acc99;float:right;}
.foot{height:50px;background:#ff6634;}
為什么學完才59%?
正確代碼:
.top{height:100px; background:#4e4e4e;}
.main{width:100%; height:600px;background:red;margin:0 auto;}
.left{ width:30%;height:600px;background:blue;float:left;}
.right{width:68%;height:600px;background:green;float:right;}
.foot{height:100px; background:#F63;}
div是塊級元素,會獨占一行。當div使用浮動以后,就會脫離原有的位置,所以多個浮動元素可以在一行內。
感覺老師很親切?。?/div>
注意冒號用英文輸入下
.top{height:100px; background:#ccc; margin:0 auto;}
.main{height:600px; background:#F63; margin:0 auto;}
.left{ width:200px; height:600px; background:blue; }
.right{margin-left:210px; width:100%; height:600px; background:#9c9; position:absolute;}
.foot{height:50px; background:#F63; margin:0;}
只要左側和右側的寬相加不等于總的寬,就可以實現左側的效果圖啦!
課程須知
1.你需要掌握html+css樣式基礎知識 2.有一定的前端實際開發經驗
老師告訴你能學到什么?
1.掌握網頁布局的相關知識 2.能對不同的網頁進行布局結構劃分 3.掌握固定寬度和自適應寬度的實現方法

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!

本次提問將花費2個積分

你的積分不足,無法發表

為什么扣積分?

本次提問將花費2個積分

繼續發表請點擊 "確定"

為什么扣積分?

舉報

0/150
提交
取消