Skip to content

Commit 8f27d93

Browse files
committed
chore(ci): blog sync
1 parent 4f456ee commit 8f27d93

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

data/blog/BFChegaodutaxian.mdx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@
88
## 高度塌陷
99
我们知道,如果一个块级元素没有设置固定的高度,那么它的高度会被高度最大的子元素撑起,如下:
1010
在容器中有 box1 和 box2 两个元素,容器的高度被 box1 撑起
11-
11+
```
1212
<div style="background-color: aqua;display:flex">
1313
<div style="height:100px;width:100px;background-color: red;line-height:100px;text-align:center;color:white">box1</div>
1414
<div style="height:50px;width:150px;background-color: blue;line-height:50px;text-align:center;color:white">box2</div>
1515
</div>
16-
16+
```
1717
如果给 box1 添加浮动、定位等,使其脱离了正常的文档流,即产生了高度塌陷
18-
18+
```
1919
<div style="background-color: aqua;">
2020
<div style="height:100px;width:100px;background-color: red;line-height:100px;text-align:center;color:white;float: left;">box1</div>
2121
<div style="height:50px;width:150px;background-color: blue;line-height:50px;text-align:center;color:white">box2</div>
2222
</div><br>
23-
23+
```
2424
## 外边距塌陷
2525
外边距塌陷也称为外边距合并,是指两个在正常流中相邻(兄弟或父子关系)的块级元素的外边距,组合在一起变成单个外边距,不过只有上下外边距才会有塌陷,左右外边距不会出现这种问题。
2626
### 兄弟元素
27+
```
2728
<div style="margin-bottom: 5px; background-color: rgb(255, 147, 147)">
2829
一寸光阴一寸金
2930
</div>
3031
<div style="margin-top: 30px; background-color: rgb(159, 159, 255)">
3132
寸金难买寸光阴
3233
</div>
33-
34+
```
3435
```
3536
<div style="margin-bottom: 5px; background-color: rgb(255, 147, 147)">
3637
一寸光阴一寸金
@@ -41,11 +42,13 @@
4142
```
4243
可以看到在有相邻 `margin-bottom``margin-top` 时,他们只会保留边距大的一个,而不是将其累加
4344
### 父子元素
45+
```
4446
<div style="background-color: rgb(224,224,224);height:300px;display:flow-root">
4547
<div style="background-color: rgb(122,122,222);width:200px;height:200px;">
4648
<div style="background-color: rgb(122,22,122);width:100px;height:100px;margin-top: 20px;"></div>
4749
</div>
4850
</div>
51+
```
4952
这种现象我们应该经常会遇到,无论是给父元素还是子元素边距,他们都会有边距。
5053
以上情形都可以通过 BFC 解决,那么什么是 BFC ?
5154

data/blog/diedaiqiheshengchengqi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
迭代器(iterator)能让我们在某个数据结构上进行遍历的对象
1010
在 JavaScript 中,迭代器是一个对象,它定义一个序列,并在终止时可能返回一个返回值。 更具体地说,迭代器是通过使用 next() 方法实现迭代器协议(Iterator protocol)的任何一个对象,该方法为无参数或者一个参数的函数
1111
该方法返回具有两个属性的对象: value,这是序列中的 next 值;和 done ,如果已经迭代到序列中的最后一个值,则它为 true 。如果 value 和 done 一起存在,则它是迭代器的返回值。
12-
一旦创建,迭代器对象可以通过重复调用next()显式地迭代。 迭代一个迭代器被称为消耗了这个迭代器,因为它通常只能执行一次。 在产生终止值之后,next()返回{donetrue}
12+
一旦创建,迭代器对象可以通过重复调用next()显式地迭代。 迭代一个迭代器被称为消耗了这个迭代器,因为它通常只能执行一次。 在产生终止值之后,next()返回`{done:true}`
1313
```
1414
//实现一个迭代器
1515
const arr = ['aaa','bbb','ccc','ddd']

0 commit comments

Comments
 (0)