- Joined
- Feb 5, 2023
- Messages
- 1
- Reaction score
- 0
I'm trying to center a button inside of a div that has a background img. I was able to position my navbar at the top and spaced evenly using flexbox. How would I center a button in this same div with background img and navbar. My code is below. I prefer it be done using flexbox, but I'm open to other suggestions.
<!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">
<title>RachelRodgersHair</title>
<style>
* {
box-sizing: border-box;
}
body {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
/* Header BG Img */
.bgimg {
background-image: url(images/2.jpeg);
min-height: 380px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* NAVBAR */
.navbar {
display: flex;
justify-content: space-evenly;
}
.navbar a {
text-decoration: none;
font-size: 20px;
padding: 14px 20px;
}
.navbar a:hover {
background-color: black;
color: white;
}
</style>
</head>
<body>
<!-- H E A D E R -->
<!-- BG IMG -->
<!-- NAVBAR -->
<div class="bgimg">
<div class="navbar">
<a href="">BOOK NOW</a>
<a href="">PRICING</a>
<a href="">CONTACT</a>
</div>
</div>
</body>
</html>
<!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">
<title>RachelRodgersHair</title>
<style>
* {
box-sizing: border-box;
}
body {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
/* Header BG Img */
.bgimg {
background-image: url(images/2.jpeg);
min-height: 380px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* NAVBAR */
.navbar {
display: flex;
justify-content: space-evenly;
}
.navbar a {
text-decoration: none;
font-size: 20px;
padding: 14px 20px;
}
.navbar a:hover {
background-color: black;
color: white;
}
</style>
</head>
<body>
<!-- H E A D E R -->
<!-- BG IMG -->
<!-- NAVBAR -->
<div class="bgimg">
<div class="navbar">
<a href="">BOOK NOW</a>
<a href="">PRICING</a>
<a href="">CONTACT</a>
</div>
</div>
</body>
</html>