For a front-end challenge from Frontend Mentor, I attempted to center a card on the screen using justify-content: center, but it doesn't seem to be working as expected. Any suggestions on how to achieve this?
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600&display=swap');
:root {
--white: hsl(0,0%,100%);
--lightgray: hsl(212,45%,89%);
--grayishblue: hsl(220,15%,55%);
--darkblue: hsl(218,44%,22%);
font-family: outfit;
font-size: 15px;
}
* {
margin: 0;
padding: 0;
}
body {
background-color: var(--lightgray);
font-family: 'outfit' sans-serif;
}
.card {
background-color: white;
max-width: 330px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
border-radius: 15px;
padding:15px;
}
img {
width: 100%;
border-radius: 20px;
}
.qr-code {
text-align: center;
}
h2 {
color: var(--darkblue);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="styles.css">
<title>Frontend Mentor | QR code component</title>
<style>
.attribution { font-size: 11px; text-align: center; }
.attribution a { color: hsl(228, 45%, 44%); }
</style>
</head>
<body>
<div class="card">
<img src="images/image-qr-code.png" alt="qr-code">
<div class="qr-code">
<h2>Improve Your front-end skills by building projects</h2>
<p>Scan the QR code to visit Frontend Mentor your coding skills to the next level</p>
</div>
</div>
<div class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="#">Your Name Here</a>.
</div>
</body>
</html>
My goal is to successfully center the card on the screen for a Frontend Mentor challenge, but I'm facing issues with using justify-content: center. Any tips on how to fix this?