Skip to content

Commit 65b3258

Browse files
committed
using flex for aligning content
1 parent c9c0570 commit 65b3258

File tree

2 files changed

+70
-21
lines changed

2 files changed

+70
-21
lines changed

practice/04 - CSS Layouts/index.html

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

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

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

5053
<img
5154
alt="HTML code on a screen"
@@ -125,35 +128,41 @@ <h3>Why should you learn HTML?</h3>
125128
<h4>Related posts</h4>
126129

127130
<ul class="related">
128-
<li>
131+
<li class="related-post">
129132
<img
130133
alt="Person programming"
131134
height="75"
132135
src="img/related-1.jpg"
133136
width="75"
134137
/>
135-
<a href="#">How to Learn Web Development</a>
136-
<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>
137142
</li>
138-
<li>
143+
<li class="related-post">
139144
<img
140145
alt="Lightning"
141146
height="75"
142147
src="img/related-2.jpg"
143148
width="75"
144149
/>
145-
<a href="#">The Unknown Powers of CSS</a>
146-
<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>
147154
</li>
148-
<li>
155+
<li class="related-post">
149156
<img
150157
alt="JavaScript code on a screen"
151158
height="75"
152159
src="img/related-3.jpg"
153160
width="75"
154161
/>
155-
<a href="#">Why JavaScript is Awesome</a>
156-
<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>
157166
</li>
158167
</ul>
159168
</aside>

practice/04 - CSS Layouts/style.css

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

200200
margin-right: 30px;
201-
margin-top: 10px;
202201
display: inline-block;
203202
}
204203

@@ -268,7 +267,7 @@ nav p {
268267
} */
269268

270269
/* FLOATS */
271-
270+
/*
272271
.author-img {
273272
float: left;
274273
margin-bottom: 20px;
@@ -310,4 +309,45 @@ aside {
310309
311310
footer {
312311
clear: both;
312+
}
313+
*/
314+
315+
/*FLEXBOX*/
316+
.main-header {
317+
display: flex;
318+
align-items: center; /* align items vertically */
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-bottom: 0;
330+
margin-left: 15px;
331+
}
332+
333+
.related-post {
334+
display: flex;
335+
align-items: center;
336+
gap: 20px;
337+
margin-bottom: 30px;
338+
}
339+
340+
.related-author {
341+
margin-bottom: 0;
342+
font-size: 14px;
343+
font-weight: normal;
344+
font-style: italic;
345+
}
346+
347+
.related-link:link {
348+
font-size: 17px;
349+
font-weight: bold;
350+
font-style: normal;
351+
margin-bottom: 5px;
352+
display: block;
313353
}

0 commit comments

Comments
 (0)