Skip to content

Commit 69b9a62

Browse files
committed
feat: clearing float issue.
1 parent 12afeb5 commit 69b9a62

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

starter/04-CSS-Layouts/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h6>The Basic Language of the Web: HTML</h6>
1818
-->
1919

2020
<div class="container">
21-
<header class="main-header">
21+
<header class="main-header clearfix">
2222
<h1>📘 The Code Magazine</h1>
2323

2424
<nav>
@@ -28,6 +28,8 @@ <h1>📘 The Code Magazine</h1>
2828
<a href="#">Flexbox</a>
2929
<a href="#">CSS Grid</a>
3030
</nav>
31+
<!-- * Old way to clearing float problem -->
32+
<!-- <div class="clear"></div> -->
3133
</header>
3234

3335
<article>
@@ -39,9 +41,10 @@ <h2>The Basic Language of the Web: HTML</h2>
3941
alt="Headshot of Laura Jones"
4042
height="50"
4143
width="50"
44+
class="author-img"
4245
/>
4346

44-
<p id="author">
47+
<p id="author" class="author">
4548
Posted by <strong>Laura Jones</strong> on Monday, June 21st 2027
4649
</p>
4750

starter/04-CSS-Layouts/style.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ body {
2222

2323
.main-header {
2424
background-color: #f7f7f7;
25+
background-color: red;
2526
/* padding: 20px;
2627
padding-left: 40px;
2728
padding-right: 40px; */
@@ -265,3 +266,38 @@ footer p {
265266
nav p {
266267
font-size: 18px;
267268
} */
269+
270+
.author-img {
271+
float: left;
272+
margin-bottom: 20px;
273+
}
274+
275+
.author {
276+
/* padding-left: 80px; */
277+
margin-top: 10px;
278+
margin-left: 20px;
279+
float: left;
280+
}
281+
282+
h1 {
283+
float: left;
284+
}
285+
286+
nav {
287+
float: right;
288+
}
289+
290+
/* Remem */
291+
/* * Old way to clearing float problem */
292+
.clear {
293+
clear: both;
294+
}
295+
296+
/* * New way to clearing float problem: clearfix hacked */
297+
.clearfix::after {
298+
clear: both;
299+
content: "";
300+
display: block;
301+
}
302+
303+
/* * !!! Remember that 'float' is an old way to layout website */

0 commit comments

Comments
 (0)