cannot center images in grid in css

I’ve been trying to complete this challenge project for Web Dev on Codecademy and I’m stuck on trying to center images in a grid. I’ve tried to use justify-content and justify-items in just about every selector within the grid and the grid container itself and cannot figure out what is wrong.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>/* Fonts */
.cinzel-decorative-regular {
font-family: "Cinzel Decorative", serif;
font-weight: 400;
font-style: normal;
}
.cinzel-decorative-bold {
font-family: "Cinzel Decorative", serif;
font-weight: 700;
font-style: normal;
}
.cinzel-decorative-black {
font-family: "Cinzel Decorative", serif;
font-weight: 900;
font-style: normal;
}
.ruthie-regular {
font-family: "Ruthie", cursive;
font-weight: 400;
font-style: normal;
}
.eb-garamond {
font-family: "EB Garamond", serif;
font-optical-sizing: auto;
font-weight: 500;
font-style: normal;
}
/* Colors */
.drab-dark-brown {
color: #313715;
}
.ecru {
color: #c4a77d;
}
.hookers-green {
color: #70877f;
}
.black-bean {
color: #280004;
}
.navy-green {
color: #393a10
}
/* Styling */
html {
font-size: 16px;
background-color: #313715;
}
.header {
display: flex;
position: relative;
align-items: center;
justify-content: space-between;
}
img {
max-width: 100%;
}
a {
text-decoration: none;
color: #70877f;
}
a:hover {
color: #A6B5B0;
cursor: pointer;
}
a:active {
color: #54645e;
}
/* .navbar {
} */
.navbar ul {
text-align: center;
list-style: none;
padding-right: 0.5rem;
}
li {
display: inline-flex;
font-family: 'Cinzel Decorative';
font-weight: 600;
font-size: 1.75rem;
padding-left: 1rem;
}
h1 {
font-family: 'Ruthie';
font-size: 4rem;
text-align: center;
color: #70877f;
text-shadow: 3px 3px 8px #2e3834;
}
.mission-container {
display: flex;
background-image: url('resources/images/apothecary-shelves.jpg');
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 25rem;
align-items: center;
justify-content: center;
}
.mission-statement {
background-color: #313715;
width: 100%;
text-align: center;
opacity: .85;
}
.mission-statement h2 {
font-size: 2.25rem;
color: #c4a77d;
margin-bottom: .2rem;
}
.mission-statement p {
font-size: 1.25rem;
margin-top: 0;
color: #c4a77d;
}
h2 {
font-family: 'Cinzel Decorative';
color: #c4a77d;
font-size: 1.85rem;
}
h3 {
font-family: 'EB Garamond';
color: #c4a77d;
font-size: 1.25rem;
text-align: center;
}
p {
font-family: 'EB Garamond';
}
/* Services */
.services-title {
text-align: center;
margin-bottom: 0;
}
.services {
display: flex;
}
.image-container {
display: grid;
grid-template-areas: 'img-1 img-2' 'img-3 img-4';
padding: .5rem;
justify-items: center;
}
.image-container h3 {
background-color: #c4a77d;
color: #313715;
/* padding: 2rem 0; */
font-size: 1.45rem;
}
.img-1,
.img-2,
.img-3,
.img-4 {
margin: 1%;
background-color: #c4a77d;
opacity: .75;
align-content: center;
}
.services img {
border: 2px solid #313715;
border-radius: 5px;
width: 90%;
justify-items: center;
}
.services h2 {
text-align: center;
}
/* Team Headshots */
.team {
display: flex;
justify-content: center;
padding-left: 5%;
}
.team-title {
text-align: center;
}
.team h2 {
width: 100%;
text-align: center;
}
.team img {
height: auto;
margin-left: 1px;
margin-right: 1px;
width: 80%;
border: 2px solid #c4a77d;
}</code>
<code>/* Fonts */ .cinzel-decorative-regular { font-family: "Cinzel Decorative", serif; font-weight: 400; font-style: normal; } .cinzel-decorative-bold { font-family: "Cinzel Decorative", serif; font-weight: 700; font-style: normal; } .cinzel-decorative-black { font-family: "Cinzel Decorative", serif; font-weight: 900; font-style: normal; } .ruthie-regular { font-family: "Ruthie", cursive; font-weight: 400; font-style: normal; } .eb-garamond { font-family: "EB Garamond", serif; font-optical-sizing: auto; font-weight: 500; font-style: normal; } /* Colors */ .drab-dark-brown { color: #313715; } .ecru { color: #c4a77d; } .hookers-green { color: #70877f; } .black-bean { color: #280004; } .navy-green { color: #393a10 } /* Styling */ html { font-size: 16px; background-color: #313715; } .header { display: flex; position: relative; align-items: center; justify-content: space-between; } img { max-width: 100%; } a { text-decoration: none; color: #70877f; } a:hover { color: #A6B5B0; cursor: pointer; } a:active { color: #54645e; } /* .navbar { } */ .navbar ul { text-align: center; list-style: none; padding-right: 0.5rem; } li { display: inline-flex; font-family: 'Cinzel Decorative'; font-weight: 600; font-size: 1.75rem; padding-left: 1rem; } h1 { font-family: 'Ruthie'; font-size: 4rem; text-align: center; color: #70877f; text-shadow: 3px 3px 8px #2e3834; } .mission-container { display: flex; background-image: url('resources/images/apothecary-shelves.jpg'); background-size: cover; background-repeat: no-repeat; width: 100%; height: 25rem; align-items: center; justify-content: center; } .mission-statement { background-color: #313715; width: 100%; text-align: center; opacity: .85; } .mission-statement h2 { font-size: 2.25rem; color: #c4a77d; margin-bottom: .2rem; } .mission-statement p { font-size: 1.25rem; margin-top: 0; color: #c4a77d; } h2 { font-family: 'Cinzel Decorative'; color: #c4a77d; font-size: 1.85rem; } h3 { font-family: 'EB Garamond'; color: #c4a77d; font-size: 1.25rem; text-align: center; } p { font-family: 'EB Garamond'; } /* Services */ .services-title { text-align: center; margin-bottom: 0; } .services { display: flex; } .image-container { display: grid; grid-template-areas: 'img-1 img-2' 'img-3 img-4'; padding: .5rem; justify-items: center; } .image-container h3 { background-color: #c4a77d; color: #313715; /* padding: 2rem 0; */ font-size: 1.45rem; } .img-1, .img-2, .img-3, .img-4 { margin: 1%; background-color: #c4a77d; opacity: .75; align-content: center; } .services img { border: 2px solid #313715; border-radius: 5px; width: 90%; justify-items: center; } .services h2 { text-align: center; } /* Team Headshots */ .team { display: flex; justify-content: center; padding-left: 5%; } .team-title { text-align: center; } .team h2 { width: 100%; text-align: center; } .team img { height: auto; margin-left: 1px; margin-right: 1px; width: 80%; border: 2px solid #c4a77d; }</code>
/* Fonts */

.cinzel-decorative-regular {
  font-family: "Cinzel Decorative", serif;
  font-weight: 400;
  font-style: normal;
}

.cinzel-decorative-bold {
  font-family: "Cinzel Decorative", serif;
  font-weight: 700;
  font-style: normal;
}

.cinzel-decorative-black {
  font-family: "Cinzel Decorative", serif;
  font-weight: 900;
  font-style: normal;
}

.ruthie-regular {
  font-family: "Ruthie", cursive;
  font-weight: 400;
  font-style: normal;
}

.eb-garamond {
  font-family: "EB Garamond", serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-style: normal;
}


/* Colors */

.drab-dark-brown {
  color: #313715;
}

.ecru {
  color: #c4a77d;
}

.hookers-green {
  color: #70877f;
}

.black-bean {
  color: #280004;
}

.navy-green {
  color: #393a10
}


/* Styling */

html {
  font-size: 16px;
  background-color: #313715;
}

.header {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
}

img {
  max-width: 100%;
}

a {
  text-decoration: none;
  color: #70877f;
}

a:hover {
  color: #A6B5B0;
  cursor: pointer;
}

a:active {
  color: #54645e;
}


/* .navbar {

} */

.navbar ul {
  text-align: center;
  list-style: none;
  padding-right: 0.5rem;
}

li {
  display: inline-flex;
  font-family: 'Cinzel Decorative';
  font-weight: 600;
  font-size: 1.75rem;
  padding-left: 1rem;
}

h1 {
  font-family: 'Ruthie';
  font-size: 4rem;
  text-align: center;
  color: #70877f;
  text-shadow: 3px 3px 8px #2e3834;
}

.mission-container {
  display: flex;
  background-image: url('resources/images/apothecary-shelves.jpg');
  background-size: cover;
  background-repeat: no-repeat;
  width: 100%;
  height: 25rem;
  align-items: center;
  justify-content: center;
}

.mission-statement {
  background-color: #313715;
  width: 100%;
  text-align: center;
  opacity: .85;
}

.mission-statement h2 {
  font-size: 2.25rem;
  color: #c4a77d;
  margin-bottom: .2rem;
}

.mission-statement p {
  font-size: 1.25rem;
  margin-top: 0;
  color: #c4a77d;
}

h2 {
  font-family: 'Cinzel Decorative';
  color: #c4a77d;
  font-size: 1.85rem;
}

h3 {
  font-family: 'EB Garamond';
  color: #c4a77d;
  font-size: 1.25rem;
  text-align: center;
}

p {
  font-family: 'EB Garamond';
}


/* Services */

.services-title {
  text-align: center;
  margin-bottom: 0;
}

.services {
  display: flex;
}

.image-container {
  display: grid;
  grid-template-areas: 'img-1 img-2' 'img-3 img-4';
  padding: .5rem;
  justify-items: center;
}

.image-container h3 {
  background-color: #c4a77d;
  color: #313715;
  /* padding: 2rem 0; */
  font-size: 1.45rem;
}

.img-1,
.img-2,
.img-3,
.img-4 {
  margin: 1%;
  background-color: #c4a77d;
  opacity: .75;
  align-content: center;
}

.services img {
  border: 2px solid #313715;
  border-radius: 5px;
  width: 90%;
  justify-items: center;
}

.services h2 {
  text-align: center;
}


/* Team Headshots */

.team {
  display: flex;
  justify-content: center;
  padding-left: 5%;
}

.team-title {
  text-align: center;
}

.team h2 {
  width: 100%;
  text-align: center;
}

.team img {
  height: auto;
  margin-left: 1px;
  margin-right: 1px;
  width: 80%;
  border: 2px solid #c4a77d;
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><head>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=Ruthie&display=swap" rel="stylesheet">
<title>Practical Magic Apothecary</title>
</head>
<body>
<div class="header">
<h1>Practical Magic Apothecary</h1>
<div class="navbar">
<nav>
<ul>
<li><a href="#mission">Mission</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#team">Team</a></li>
</ul>
</nav>
</div>
</div>
<div class="mission-container" id="mission">
<div class="mission-statement">
<h2>Practical Magic Apothecary</h2>
<p>We specialize in procuring and providing all your herbal and metaphysical needs.</p>
</div>
</div>
<h2 class="services-title">Our Services</h2>
<div class="services" id="services">
<div class="image-container">
<div class="img-1">
<h3>Herbal Mixes</h3>
<img src="resources/images/potion-pouring.jpg" alt="a person pouring liquid into a mortar">
</div>
<div class="img-2">
<h3>Spelled Candles</h3>
<img src="resources/images/candle.jpg" alt="several candles with one lit">
</div>
<div class="img-3">
<h3>Herbal Tinctures</h3>
<img src="resources/images/tincture.jpg" alt="pouring a tincture onto hand">
</div>
<div class="img-4">
<h3>Organic Herbs</h3>
<img src="resources/images/ingredients.jpg" alt="different herbal ingredients">
</div>
</div>
</div>
<div class="team-title">
<h2>Meet the Coven</h2>
</div>
<div class="team" id="team">
<div class="headshot-1">
<img src="resources/images/headshot1.jpg" alt="headshot of owner">
<h3>Owner</h3>
</div>
<div class="headshot-2">
<img src="resources/images/headshot2.jpg" alt="headshot of manager">
<h3>Manager</h3>
</div>
<div class="headshot-3">
<img src="resources/images/headshot3.jpg" alt="headshot of herbalist">
<h3>Herbalist</h3>
</div>
</div>
</body></code>
<code><head> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="styles.css"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=Ruthie&display=swap" rel="stylesheet"> <title>Practical Magic Apothecary</title> </head> <body> <div class="header"> <h1>Practical Magic Apothecary</h1> <div class="navbar"> <nav> <ul> <li><a href="#mission">Mission</a></li> <li><a href="#services">Services</a></li> <li><a href="#team">Team</a></li> </ul> </nav> </div> </div> <div class="mission-container" id="mission"> <div class="mission-statement"> <h2>Practical Magic Apothecary</h2> <p>We specialize in procuring and providing all your herbal and metaphysical needs.</p> </div> </div> <h2 class="services-title">Our Services</h2> <div class="services" id="services"> <div class="image-container"> <div class="img-1"> <h3>Herbal Mixes</h3> <img src="resources/images/potion-pouring.jpg" alt="a person pouring liquid into a mortar"> </div> <div class="img-2"> <h3>Spelled Candles</h3> <img src="resources/images/candle.jpg" alt="several candles with one lit"> </div> <div class="img-3"> <h3>Herbal Tinctures</h3> <img src="resources/images/tincture.jpg" alt="pouring a tincture onto hand"> </div> <div class="img-4"> <h3>Organic Herbs</h3> <img src="resources/images/ingredients.jpg" alt="different herbal ingredients"> </div> </div> </div> <div class="team-title"> <h2>Meet the Coven</h2> </div> <div class="team" id="team"> <div class="headshot-1"> <img src="resources/images/headshot1.jpg" alt="headshot of owner"> <h3>Owner</h3> </div> <div class="headshot-2"> <img src="resources/images/headshot2.jpg" alt="headshot of manager"> <h3>Manager</h3> </div> <div class="headshot-3"> <img src="resources/images/headshot3.jpg" alt="headshot of herbalist"> <h3>Herbalist</h3> </div> </div> </body></code>
<head>
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  <link rel="stylesheet" href="styles.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=Ruthie&display=swap" rel="stylesheet">

  <title>Practical Magic Apothecary</title>
</head>

<body>
  <div class="header">
    <h1>Practical Magic Apothecary</h1>
    <div class="navbar">
      <nav>
        <ul>
          <li><a href="#mission">Mission</a></li>
          <li><a href="#services">Services</a></li>
          <li><a href="#team">Team</a></li>
        </ul>
      </nav>
    </div>
  </div>
  <div class="mission-container" id="mission">
    <div class="mission-statement">
      <h2>Practical Magic Apothecary</h2>
      <p>We specialize in procuring and providing all your herbal and metaphysical needs.</p>
    </div>
  </div>
  <h2 class="services-title">Our Services</h2>
  <div class="services" id="services">
    <div class="image-container">
      <div class="img-1">
        <h3>Herbal Mixes</h3>
        <img src="resources/images/potion-pouring.jpg" alt="a person pouring liquid into a mortar">
      </div>
      <div class="img-2">
        <h3>Spelled Candles</h3>
        <img src="resources/images/candle.jpg" alt="several candles with one lit">
      </div>
      <div class="img-3">
        <h3>Herbal Tinctures</h3>
        <img src="resources/images/tincture.jpg" alt="pouring a tincture onto hand">
      </div>
      <div class="img-4">
        <h3>Organic Herbs</h3>
        <img src="resources/images/ingredients.jpg" alt="different herbal ingredients">
      </div>
    </div>
  </div>
  <div class="team-title">
    <h2>Meet the Coven</h2>
  </div>
  <div class="team" id="team">
    <div class="headshot-1">
      <img src="resources/images/headshot1.jpg" alt="headshot of owner">
      <h3>Owner</h3>
    </div>
    <div class="headshot-2">
      <img src="resources/images/headshot2.jpg" alt="headshot of manager">
      <h3>Manager</h3>
    </div>
    <div class="headshot-3">
      <img src="resources/images/headshot3.jpg" alt="headshot of herbalist">
      <h3>Herbalist</h3>
    </div>
  </div>
</body>

New contributor

user25561018 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật