-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreflow.html
63 lines (55 loc) · 2.43 KB
/
reflow.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reflow</title>
<style>
.box {
color: white;
width: 100px;
height: 100px;
margin: 10px;
background: lightblue;
}
</style>
</head>
<body>
<div class="box" id="box1">1</div>
<div class="box" id="box2">2</div>
<div class="box" id="box3">3</div>
<div class="box" id="box4">4</div>
<div class="box" id="box5">5</div>
<br>
<a href="https://gist.github.com/faressoft/36cdd64faae21ed22948b458e6bf04d5" target="_blank">参考</a>
<script>
// read then write triger layout
// 6 reflows(layout)
// var box1Height = document.getElementById('box1').clientHeight;
// document.getElementById('box1').style.height = box1Height + 10 + 'px';
// var box2Height = document.getElementById('box2').clientHeight;
// document.getElementById('box2').style.height = box2Height + 10 + 'px';
// var box3Height = document.getElementById('box3').clientHeight;
// document.getElementById('box3').style.height = box3Height + 10 + 'px';
// var box4Height = document.getElementById('box4').clientHeight;
// document.getElementById('box4').style.height = box4Height + 10 + 'px';
// var box5Height = document.getElementById('box5').clientHeight;
// document.getElementById('box5').style.height = box5Height + 10 + 'px';
// var box6Height = document.getElementById('box6').clientHeight;
// document.getElementById('box6').style.height = box6Height + 10 + 'px';
// 1 reflows
var box1Height = document.getElementById('box1').clientHeight;
var box2Height = document.getElementById('box2').clientHeight;
var box3Height = document.getElementById('box3').clientHeight;
var box4Height = document.getElementById('box4').clientHeight;
var box5Height = document.getElementById('box5').clientHeight;
var box6Height = document.getElementById('box6').clientHeight;
document.getElementById('box1').style.height = box1Height + 10 + 'px';
document.getElementById('box2').style.height = box2Height + 10 + 'px';
document.getElementById('box3').style.height = box3Height + 10 + 'px';
document.getElementById('box4').style.height = box4Height + 10 + 'px';
document.getElementById('box5').style.height = box5Height + 10 + 'px';
document.getElementById('box6').style.height = box6Height + 10 + 'px';
</script>
</body>
</html>