I need help! How can I vertically center the .tagline-container within a div that has two children divs, without affecting the positioning of the nav?
<div class="header">
<nav class="navbar">
<h1>Rainey 13 Foundation</h1>
<ul class="nav-items">
<li class="nav-item">
<a href="#" class="nav-link">Home</a>
<a href="#" class="nav-link">About</a>
<a href="#" class="nav-link">Contact</a>
<a href="#" class="nav-link">Donate</a>
</li>
</ul>
</nav>
<div class="tagline-container">
<h1 class="tagline">Fostering the First Steps, and Beyond!</h1>
</div>
Snippet of CSS code used:
.header {
background-image: url(./img/background.jpg);
background-size: cover;
width: 100vw;
height: 100vh;
display: flex;
}
.tagline-container {
align-items: center;
justify-content: center;
}
The issue is that the current setup does not achieve the desired vertical centering.
Complete HTML and CSS code snippet below:
@font-face {
font-family: NATS;
src: url(./fonts/NATS-Regular.ttf);
}
* {
margin: 0;
padding: 0;
font-family: NATS;
}
.header {
display: inline-block;
background-image: url(./img/background.jpg);
background-size: cover;
width: 100vw;
height: 100vh;
display: flex;
}
.tagline-container {
display: flex;
align-items: center;
justify-content: center;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rainey 13 Foundation</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="header">
<nav class="navbar">
<span>Rainey 13 Foundation</span>
<ul class="nav-items">
<li class="nav-item">
<a href="#" class="nav-link">Home</a>
<a href="#" class="nav-link">About</a>
<a href="#" class="nav-link">Contact</a>
<a href="#" class="nav-link">Donate</a>
</li>
</ul>
</nav>
<div class="tagline-container">
<h1 class="tagline">Fostering the First Steps, and Beyond!</h1>
</div>
</div>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>