三、双飞翼模型

三、双飞翼模型

3.1 原理

浮动元素margin-left:负数,表示相对于上一个元素位置偏移。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.box {
width: 700px;
height: 100px;
border: 1px solid #000;
}
.box p {
float: left;
width: 100px;
height: 100px;
background-color: red;
}
.box .no2 {
background-color: green;
/* margin-left:负数 表示相对于no1位置偏移 */
margin-left: -50px;
opacity: 0.2;
}
.box .no3 {
background-color: blue;
}

NIYrtO.png

3.2 双飞翼模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<div class="box">
<div class="main">主内容</div>
</div>
<div class="left"></div>
<div class="right"></div>

/* box left right 同级的浮动元素 */
.box {
/* 通栏效果 */
float: left;
width: 100%;
height: 200px;
background-color: #eee;
}
.box .main {
/* 标准流 宽度自适应 标准流不设置宽度
同时设置margin:正数 也会占有位置
子盒子不设置宽度 子盒子实际占有宽度(包含margin)撑满父盒子内容宽度
*/
margin: 0px 210px;
height: 200px;
background-color: green;
}
.left {
float: left;
/* 固定宽度 */
width: 200px;
height: 300px;
background-color: red;
/* 相对于no1位置的偏移 */
margin-left: -100%;
}
.right {
float: left;
/* 固定宽度 */
width: 200px;
height: 400px;
background-color: blue;
/* 移动自身宽度 */
margin-left: -200px;
}

NINGQJ.png

点击查看

本文标题:三、双飞翼模型

文章作者:Mango

发布时间:2020年06月30日 - 21:36:22

最后更新:2020年06月30日 - 21:44:19

原始链接:https://mango185.github.io/post/ea9a79da.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------------本文结束 感谢您的阅读-------------------