<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<style>
/*方式一 float+margin
.all{
height:500px
}
.left{
float:left;
width:200px;
background-color:red;
height:100%;
}
.right{
width:100%;
height:100%;
margin-left:200px;
background-color:yellow;
}
*/
/*方式二 float+overflow:hidden
.all{
height:500px
}
.left{
float:left;
width:200px;
background-color:red;
height:100%;
}
.right{
overflow:hidden;
height:100%;
background-color:yellow;
}
*/
/*方式三 flex */
.all{
height:500px;
display:flex;
}
.left{
width:200px;
background-color:red;
height:100%;
}
.right{
flex:1;
height:100%;
background-color:yellow;
display: flex; //為了后面的上下布局
flex-direction: column; //為了后面的上下布局
}
.top{
height: 100px;
background-color: blue;
}
.bottom{
flex: 1;
background-color: black;
}
/*方式四 絕對定位absolute
.all{
height:500px;
position: relative;
}
.left{
width:200px;
background-color:red;
height:100%;
}
.right{
position:absolute;
left: 200px;
top: 0px;
bottom: 0px;
right: 0px;
background-color: yellow;
}
.top{
height: 100px;
background-color: blue;
}
.bottom{
position: absolute;
background-color: black;
top: 100px;
bottom: 0px;
left: 0px;
right: 0px;
}*/
</style>
</head>
<body>
<div class="all">
<div class="left"></div>
<div class="right">
<div class="top">
</div>
<div class="bottom">
</div>
</div>
</div>
</body>
<script>
</script>
</html>
css左右布局+上下布局
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事?!?“怎么了?”我有些...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...