布局在html中是不不可少的,双飞翼是经典的布局。
作用在于主体优先渲染,他和圣杯布局最大的区别在于。他在主体内容的上一级在嵌套一个盒子,指定盒子宽度继承父级。
左和右用margin指定位置。主体内容使用margin来挤压得到
以下是我的手写关于双飞翼和圣杯的区别

以下是我的代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>双飞翼布局</title>
<style>
body{
margin: 0;
padding: 0;
}
.header{
width: 100%;
height: 100px;
background: powderblue;
}
.footer{
width: 100%;
height: 100px;
background: powderblue;
}
.content{
width: 1000px;
min-height: 100%;
margin: 0 auto;
background: #0388f1;
text-align: center;
line-height: 100px;
}
.container{
width: 1000px;
margin: auto;
overflow: hidden;
text-align: center;
background: powderblue;
}
.wrap{
width: 100%;
float: left;
background: #ffe80e;
}
.main{
min-height: 800px;
background: hotpink;
margin:0 150px;
}
.left{
width: 150px;
min-height: 800px;
float: left;
background: indianred;
margin-left: -100%;
}
.right{
width: 150px;
min-height: 800px;
float: left;
background: limegreen;
margin-left: -150px;
}
ul{
margin: 0;
padding: 0;
}
ul li{
list-style: none;
display: block;
float: left;
margin-left: 100px;
}
a{
text-decoration: none;
color: white;
}
a:llink{
color: white;
}
a:visited{
color: white;
}
.maid1{
width: 100%;
min-height: 400px;
}
.maid2{
width: 100%;
min-height: 400px;
}
.zuo {
width: 200px;
height: 300px;
background: white;
float: left;
margin-top: 50px;
margin-left: 25px;
}
.zhong {
width: 200px;
height: 300px;
background: white;
float: left;
margin-top: 50px;
margin-left: 25px;
}
.you {
width: 200px;
height: 300px;
background: white;
float: left;
margin-top: 50px;
margin-left: 25px;
}
.left1 {
width: 100%;
height: 395px;
background: #ffe80e;
margin-bottom: 10px;
}
.left2{
width: 100%;
height: 395px;
background: beige;
}
.right1 {
width: 100%;
height: 395px;
background: #ffe80e;
margin-bottom: 10px;
}
.right2{
width: 100%;
height: 395px;
background: beige;
}
</style>
</head>
<body>
<div class="header">
<div class="content">
<ul>
<li><a href="test">首页</a></li>
<li><a href="test">新闻</a></li>
<li><a href="test">娱乐</a></li>
<li><a href="test">音乐</a></li>
<li><a href="test">关于我们</a></li>
<li><a href="test">联系我们</a></li>
</ul>
</div>
</div>
<div class="container">
<div class="wrap">
<div class="main">
<div class="maid1">
<div class="zuo"></div>
<div class="zhong"></div>
<div class="you"></div>
</div>
<div class="maid2">
<div class="zuo"></div>
<div class="zhong"></div>
<div class="you"></div>
</div>
</div>
</div>
<div class="left">
<div class="left1"></div>
<div class="left2"></div>
</div>
<div class="right">
<div class="right1"></div>
<div class="right2"></div>
</div>
</div>
<div class="footer">
<div class="content">
<ul>
<li><a href="test">首页</a></li>
<li><a href="test">新闻</a></li>
<li><a href="test">娱乐</a></li>
<li><a href="test">音乐</a></li>
<li><a href="test">关于我们</a></li>
<li><a href="test">联系我们</a></li>
</ul>
</div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号