Skip to content

Commit 86a6216

Browse files
authored
Merge pull request mdn#55 from paulsmithkc/master
correcting sticky footer example
2 parents f654ff6 + 96c8090 commit 86a6216

File tree

2 files changed

+55
-40
lines changed

2 files changed

+55
-40
lines changed

css-cookbook/sticky-footer-flexbox--download.html

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,45 @@
1010

1111

1212
<style>
13-
html {
14-
height:100%;
15-
box-sizing: border-box;
16-
}
17-
13+
html,
1814
body {
15+
box-sizing: border-box;
1916
height: 100%;
20-
background-color: #fff;
21-
color: #333;
22-
font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
2317
padding: 0;
2418
margin: 0;
2519
}
2620

27-
* {
28-
box-sizing: inherit;
29-
}
30-
3121
.wrapper {
22+
box-sizing: border-box;
3223
min-height: 100%;
3324
display: flex;
3425
flex-direction: column;
3526
}
3627

3728
.page-header,
3829
.page-footer {
39-
background-color: rgb(75, 70, 74);
40-
color: #fff;
41-
padding: 20px;
30+
flex-grow: 0;
4231
flex-shrink: 0;
4332
}
4433

4534
.page-body {
46-
padding: 20px;
4735
flex-grow: 1;
4836
}
4937

50-
.preview {
51-
height: 400px;
52-
overflow: auto;
38+
/* For demonstration only, not part of the recipe */
39+
body {
40+
background-color: #fff;
41+
color: #333;
42+
font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
43+
}
44+
.page-header,
45+
.page-footer {
46+
background-color: rgb(75, 70, 74);
47+
color: #fff;
48+
padding: 20px;
49+
}
50+
.page-body {
51+
padding: 20px;
5352
}
5453
</style>
5554

css-cookbook/sticky-footer-flexbox.html

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,61 @@
1010
<link rel="stylesheet" href="styles.css">
1111

1212
<style>
13-
html {
14-
height:100%;
15-
box-sizing: border-box;
16-
}
17-
1813
* {
19-
box-sizing: inherit;
14+
box-sizing: border-box;
2015
}
21-
16+
html,
2217
body {
18+
box-sizing: border-box;
2319
height: 100%;
20+
padding: 0;
21+
margin: 0;
2422
}
2523

2624
.page-header,
2725
.page-footer {
2826
background-color: rgb(75, 70, 74);
2927
color: #fff;
3028
padding: 20px;
31-
flex-shrink: 0;
3229
}
3330

3431
.page-body {
3532
padding: 20px;
36-
flex-grow: 1;
3733
}
3834

3935
.preview {
40-
height: 100%;
36+
height: 400px;
37+
overflow: auto;
38+
}
39+
40+
.playable-css {
41+
min-height: 420px;
42+
overflow: auto;
43+
}
44+
45+
.playable-html {
46+
min-height: 160px;
4147
overflow: auto;
4248
}
4349
</style>
4450

4551
<style class="editable">
52+
html, body {
53+
box-sizing: border-box;
54+
height: 100%;
55+
padding: 0;
56+
margin: 0;
57+
}
4658
.wrapper {
59+
box-sizing: border-box;
4760
min-height: 100%;
4861
display: flex;
4962
flex-direction: column;
5063
}
51-
52-
.page-header,
53-
.page-footer {
64+
.page-header, .page-footer {
65+
flex-grow: 0;
5466
flex-shrink: 0;
5567
}
56-
5768
.page-body {
5869
flex-grow: 1;
5970
}
@@ -72,31 +83,36 @@
7283
</div>
7384
</section>
7485

75-
<textarea class="playable playable-css">
86+
<textarea class="playable playable-css">
87+
html, body {
88+
box-sizing: border-box;
89+
height: 100%;
90+
padding: 0;
91+
margin: 0;
92+
}
7693
.wrapper {
94+
box-sizing: border-box;
7795
min-height: 100%;
7896
display: flex;
7997
flex-direction: column;
8098
}
81-
82-
.page-header,
83-
.page-footer {
99+
.page-header, .page-footer {
100+
flex-grow: 0;
84101
flex-shrink: 0;
85102
}
86-
87103
.page-body {
88104
flex-grow: 1;
89105
}
90106
</textarea>
91107

92-
<textarea class="playable playable-html">
108+
<textarea class="playable playable-html">
93109
<div class="wrapper">
94110
<header class="page-header">This is the header</header>
95111
<main class="page-body">
96112
<p>Main page content here, add more if you want to see the footer push down.</p>
97113
</main>
98114
<footer class="page-footer">Sticky footer</footer>
99-
</div>
115+
</div>
100116
</textarea>
101117

102118
<div class="playable-buttons">

0 commit comments

Comments
 (0)