Tell us what’s happening:
Cool way to learn to use flex boxes! I’m in the middle of working on the layout of my 4 of heart now but couldn’t figure out why the middle part are so far from each other vertically. I put a solid border up to make it easier for me to see. I thought align-items: center would bring it in together, but somehow the current layout looks like it’s being affected by something else. Any hints? Thanks!
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Playing Cards</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main id="playing-cards">
<div class="card">
<div class="left">
<div>2</div>
<div>♣</div>
</div>
<div class="middle one-col">
<div>♣</div>
<div>♣</div>
</div>
<div class="right">
<div>2</div>
<div>♣</div>
</div>
</div>
<div class="card">
<div class="left">
<div>5</div>
<div>♠</div>
</div>
<div class="middle two-col odd">
<div>♠</div>
<div>♠</div>
<div>♠</div>
<div>♠</div>
<div>♠</div>
</div>
<div class="right">
<div>5</div>
<div>♠</div>
</div>
</div>
<div class="card red">
<div class="left">
<div>4</div>
<div>♥</div>
</div>
<div class="middle two-col">
<div>♥</div>
<div>♥</div>
<div>♥</div>
<div>♥</div>
</div>
<div class="right">
<div>4</div>
<div>♥</div>
</div>
</div>
<div class="card red">
<div class="left">
<div>3</div>
<div>♦</div>
</div>
<div class="middle one-col">
<div>♦</div>
<div>♦</div>
<div>♦</div>
</div>
<div class="right">
<div>3</div>
<div>♦</div>
</div>
</div>
<div class="card red">
<div class="left">
<div>A</div>
<div>♦</div>
</div>
<div class="middle one-col">
<div>♦</div>
</div>
<div class="right">
<div>A</div>
<div>♦</div>
</div>
</div>
</main>
</body>
</html>
/* file: styles.css */
body {
background-color: pink;
}
#playing-cards {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
margin-top: 100px;
}
.card {
display: flex;
justify-content: space-between;
width: 200px;
height: 300px;
border: 1px solid black;
border-radius: 10px;
background-color: white;
}
.red {
color: red;
}
.left {
display: flex;
justify-content: flex-start;
padding: 15px;
font-size: 1.4em;
flex-direction: column;
}
.middle {
display: flex;
justify-content: center;
font-size: 3.5em;
align-items: center;
width: 100px;
}
.right {
display: flex;
transform: rotate(180deg);
flex-direction: column;
align-items: flex-start;
padding: 15px;
font-size: 1.4em;
}
.one-col {
display: flex;
flex-direction: column;
}
.two-col {
display: flex;
flex-wrap: wrap;
width: 80px;
gap: 5px;
border: 1px solid black;
align-items: center;
}
.odd {
display: flex;
justify-content:
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Challenge Information:
Build a Page of Playing Cards - Build a Page of Playing Cards