帮我写一段代码说明css 双飞翼布局和圣杯布局
时间: 2023-05-21 17:02:21 浏览: 126
当然可以,以下是 CSS 双飞翼布局和圣杯布局的代码示例:
CSS 双飞翼布局:
HTML 代码:
```
<div class="container">
<div class="left"></div>
<div class="content"></div>
<div class="right"></div>
</div>
```
CSS 代码:
```
.container {
width: 100%;
height: 300px;
margin: 0 auto;
position: relative;
}
.left, .right {
width: 200px;
height: 100%;
float: left;
}
.content {
width: 100%;
height: 100%;
margin: 0 200px;
}
```
圣杯布局:
HTML 代码:
```
<div class="container">
<div class="content"></div>
<div class="left"></div>
<div class="right"></div>
</div>
```
CSS 代码:
```
.container {
width: 100%;
height: 300px;
margin: 0 auto;
position: relative;
}
.left, .right, .content {
height: 100%;
position: relative;
float: left;
}
.left {
width: 200px;
margin-left: -100%;
right: 200px;
}
.right {
width: 200px;
margin-right: -100%;
left: 200px;
}
.content {
width: 100%;
margin: 0 200px;
}
```
希望这段代码能够帮助你理解 CSS 双飞翼布局和圣杯布局。
阅读全文