Skip to content

Commit 2f6e16d

Browse files
张欧文张欧文
张欧文
authored and
张欧文
committed
use flex
1 parent fefa078 commit 2f6e16d

File tree

3 files changed

+75
-27
lines changed

3 files changed

+75
-27
lines changed

starter/04-CSS-Layouts/flexbox.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.el--1 {
1010
background-color: blueviolet;
1111
align-self: flex-start;
12-
order: 2;
12+
/* order: 2; */
1313
}
1414
.el--2 {
1515
background-color: orangered;
@@ -27,7 +27,7 @@
2727
}
2828
.el--6 {
2929
background-color: steelblue;
30-
order: -1;
30+
/* order: -1; */
3131
}
3232
.el--7 {
3333
background-color: yellow;
@@ -39,7 +39,7 @@
3939
.el {
4040
/* margin-right: 10px; */
4141
/* flex-basis: 200px; */
42-
flex: 0 0 10px;
42+
flex: 1 1 10px;
4343
}
4444
.container {
4545
/* STARTER */
@@ -52,7 +52,7 @@
5252
display: flex;
5353
align-items: center;
5454
justify-content: flex-start;
55-
gap: 30px;
55+
gap: 0;
5656
}
5757
</style>
5858
</head>
@@ -63,9 +63,9 @@
6363
<div class="el el--3">CSS</div>
6464
<div class="el el--4">are</div>
6565
<div class="el el--5">amazing</div>
66-
<div class="el el--6">languages</div>
66+
<!-- <div class="el el--6">languages</div>
6767
<div class="el el--7">to</div>
68-
<div class="el el--8">learn</div>
68+
<div class="el el--8">learn</div> -->
6969
</div>
7070
</body>
7171
</html>

starter/04-CSS-Layouts/index.html

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ <h1>📘 The Code Magazine</h1>
3636
<header class="post-header">
3737
<h2>The Basic Language of the Web: HTML</h2>
3838

39-
<img
40-
src="img/laura-jones.jpg"
41-
alt="Headshot of Laura Jones"
42-
height="50"
43-
width="50"
44-
class="author-img"
45-
/>
39+
<div class="author-box">
40+
<img
41+
src="img/laura-jones.jpg"
42+
alt="Headshot of Laura Jones"
43+
height="50"
44+
width="50"
45+
class="author-img"
46+
/>
4647

47-
<p id="author">
48-
Posted by <strong>Laura Jones</strong> on Monday, June 21st 2027
49-
</p>
48+
<p id="author">
49+
Posted by <strong>Laura Jones</strong> on Monday, June 21st 2027
50+
</p>
51+
</div>
5052

5153
<img
5254
src="img/post-img.jpg"
@@ -126,35 +128,41 @@ <h3>Why should you learn HTML?</h3>
126128
<h4>Related posts</h4>
127129

128130
<ul class="related">
129-
<li>
131+
<li class="related-post">
130132
<img
131133
src="img/related-1.jpg"
132134
alt="Person programming"
133135
width="75"
134136
height="75"
135137
/>
136-
<a href="#">How to Learn Web Development</a>
137-
<p class="related-author">By Jonas Schmedtmann</p>
138+
<div>
139+
<a class="related-link" href="#">How to Learn Web Development</a>
140+
<p class="related-author">By Jonas Schmedtmann</p>
141+
</div>
138142
</li>
139-
<li>
143+
<li class="related-post">
140144
<img
141145
src="img/related-2.jpg"
142146
alt="Lightning"
143147
width="75"
144148
height="75"
145149
/>
146-
<a href="#">The Unknown Powers of CSS</a>
147-
<p class="related-author">By Jim Dillon</p>
150+
<div>
151+
<a class="related-link" href="#">The Unknown Powers of CSS</a>
152+
<p class="related-author">By Jim Dillon</p>
153+
</div>
148154
</li>
149-
<li>
155+
<li class="related-post">
150156
<img
151157
src="img/related-3.jpg"
152158
alt="JavaScript code on a screen"
153159
width="75"
154160
height="75"
155161
/>
156-
<a href="#">Why JavaScript is Awesome</a>
157-
<p class="related-author">By Matilda</p>
162+
<div>
163+
<a class="related-link" href="#">Why JavaScript is Awesome</a>
164+
<p class="related-author">By Matilda</p>
165+
</div>
158166
</li>
159167
</ul>
160168
</aside>

starter/04-CSS-Layouts/style.css

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ nav a:link {
198198
display: block; */
199199

200200
margin-right: 30px;
201-
margin-top: 10px;
201+
margin-top: 0;
202202
display: inline-block;
203203
}
204204

@@ -267,7 +267,7 @@ nav p {
267267
font-size: 18px;
268268
} */
269269

270-
/* float */
270+
/* float
271271
.author-img {
272272
float: left;
273273
}
@@ -310,3 +310,43 @@ footer {
310310
.related {
311311
margin: 0;
312312
}
313+
*/
314+
315+
/* flex */
316+
.main-header {
317+
display: flex;
318+
align-items: center;
319+
justify-content: space-between;
320+
}
321+
322+
.author-box {
323+
display: flex;
324+
align-items: center;
325+
margin-bottom: 15px;
326+
}
327+
328+
#author {
329+
margin: 0 0;
330+
margin-left: 15px;
331+
}
332+
333+
.related-post {
334+
display: flex;
335+
align-items: center;
336+
gap: 20px;
337+
}
338+
339+
.related-link:link {
340+
font-size: 17px;
341+
font-weight: bold;
342+
font-style: normal;
343+
margin-bottom: 5px;
344+
display: block;
345+
}
346+
347+
.related-author {
348+
margin-bottom: 0;
349+
font-size: 14px;
350+
font-weight: normal;
351+
font-style: italic;
352+
}

0 commit comments

Comments
 (0)