Can someone explain why the align-items property in this code is centering child elements on the x-axis instead of the y-axis? Also, the justify-content: center doesn't seem to have any effect. Even when I remove justify-content, the items are still aligned on the x-axis due to align-items property:
/* HTML: */
<div class="page">
<div class="navbar">
<div class="leftSide">
<img src="./assets/images/logo.png">
</div>
<div class="rightSide">
<li><a href="#">Home</a></li>
<li><a href="#">Menu</a></li>
<li><a href="#">What's New</a></li>
<li><a href="#">Contact Us</a></li>
</div>
</div>
<div class="content">
<h1>It's not just Coffee</h1>
<h1>It's <span>Starbucks</span></h1>
</div>
</div>
/* CSS: */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800;900&display=swap');
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
.page {
display: flex;
align-items: center;
flex-direction: column;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20px;
position: sticky;
top: 0;
}
.rightSide {
display: flex;
list-style: none;
}
.rightSide li{
margin-right: 30px;
}
.rightSide li a {
text-decoration: none;
color: black;
position: relative;
transition: all 0.5s;
}
.rightSide li a::before {
content: '';
width: 0%;
}
.rightSide li a:hover::before {
content: '';
position: absolute;
width: 100%;
height: 1px;
background: #000;
bottom: 0;
left: 0;
}
.leftSide img {
width: 80px;
height: 80px;
margin-left: 15px;
}
I've tried various solutions and searched extensively, but so far, I couldn't find a way to correct it. This isn't the first time facing this issue.