负 margin 写法
- html
<div>
<div class="aside">
<p>左侧布局</p>
<p>左侧布局</p>
<p>左侧布局</p>
<p>左侧布局</p>
</div>
<div class="main">
主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容主题内容
</div>
</div>
- css
.wrap {
width: 100%;
background: #f00;
overflow: hidden; // 创建BFC,防止浮动撑不起高度
}
.wrap .aside {
width: 300px;
background: #0ff;
float: left;
}
.wrap .main {
background: #00f;
margin-right: -300px;
overflow: hidden;
}
.wrap {
width: 100%;
display: flex;
flex-decoration: row;
justify-content: flex-start;
}
.wrap .aside {
width: 300px;
}
.wrap .main {
flex: 1;
}