CSS Images and captions

I’m stuck at the project tea cozy, I’m having a hard time trying to figure out how to align images on multiple rows in the centered each with a text description under them. Not using flexbox I can get the images to line up in a column with the text under them but as soon as i set the display type to flex the text goes right beside it and not under it. Please help here is my CSS code:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: black;
    color: seashell;
    font-size: 22px;
    opacity: 0.9;
    font-family: 'Helvetica', Arial, sans-serif;
}

header {
    width: 100%;
    border-bottom: 1px solid seashell;
    position: fixed;
    z-index: 10;
    height: 69px;
    background-color: transparent;

}


.topnav-right a {
    color: seashell;;
    margin-left: 30px;
    margin-right: 0px;
    text-decoration: underline;
}

.topnav-right {
    color: seashell;
    text-align: center;
    float: right;
    padding: 0 15px;
    height: 69px;
    margin-top: 17px;
}

.topnav {
    display: inline-block;
    height: 69px;
    width: 200px;
    position: relative;
}

.topnav img {
    max-height: 50px;
    max-width: 200px;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}

/* --------------------------------------- */

.background {
    background-image: url(https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-mission-background.jpg);
    height: 700px;
    width: 1200px;
    position: relative;
    margin: 0 auto;
    top: 69px;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

.background h2,
.background h4 {
    text-align: center;
    background-color: black;
    width: 100%;
}

.background h2 {
    padding-top: 20px;
}
.background h4 {
    padding-bottom: 20px;
}

/* -------------------------------------------- */

.monthlyImages {
    width: 1000px;
    margin: 0 auto;
    text-align: center;
    display: inline-flex;
    position: relative;
    top: 70px;
}

.monthlyImages Img {
    width: 300px;
    height: 200px;
    margin-right: 10px;
    display: inline;
}

figcaption.caption {
    display: block;
}

Html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Tea Cozy</title>
  <link href="./css/styles.css" rel="stylesheet" type="text/css">
</head>
<body>

  <header>
    <div class="topnav">
      <img class="logo" src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-tea-cozy-logo.png">
    </div>
    <div class="topnav-right">
      <a href="#home">Home</a>
      <a href="#featured-tea">Featured Tea</a>
      <a href="#locations">Locations</a>
    </div>
  </header>


  <div class="background"> 
    <h2>Our Mission</h2>
    <h4>Handpicked, Artisanally Curated, Free Rangem Sustainable, Small Batch, Fair Trade, Organic Tea</h4>
  </div>

  <div class="monthlyTea">

  </div>

  <div class="monthlyImages">
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-berryblitz.jpg"></figure>
   <figcaption class="caption">Berry Blitz Tea</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-spiced-rum.jpg"></figure>
    <figcaption class="caption">Spiced Rum</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-donut.jpg"></figure>
    <figcaption class="caption">Donut</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-myrtle-ave.jpg"></figure>
    <figcaption class="caption">Myrtle Ave</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-bedford-bizarre.jpg"></figure>
    <figcaption class="caption">Bedford Bizarre</figcaption>
  </div>

</body>
</html>

The last part in each code is what im having trouble grasping.

I modified a bit the CSS file and I think this is what you want.

.monthlyImages {
width: 60%;
margin: 0 auto;
text-align: center;
display: inline-flex;
position: relative;
top: 100px;
}

.monthlyImages Img {
width: 300px;
height: 200px;
margin-right: 10px;
display: inline;
}

figcaption.caption {
display: inline-flex;
text-align: center;
margin-top: 22%;
margin-left: auto;
margin-right: auto;
position: relative;
right: 15%;
}

I modified the last part where the line was. I made it look a little bit nicer and changed the px to % to be more mobile-friendly. All the photos are alligned and their text is under them. Reply if this is ok, please. Good luck!

Yes this is exactly how I want the image text to be displayed however I want the images to go into two columns, so there’s three at the top and two at the bottom. When I try to change it using flex-wrap: wrap; it completely messes everything up.

Here is the updated CSS Code (Not much changed…)

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: black;
    color: seashell;
    font-size: 22px;
    opacity: 0.9;
    font-family: 'Helvetica', Arial, sans-serif;
}

header {
    width: 100%;
    border-bottom: 1px solid seashell;
    position: fixed;
    z-index: 10;
    height: 69px;
    background-color: black;

}


.topnav-right a {
    color: seashell;;
    margin-left: 30px;
    margin-right: 0px;
    text-decoration: underline;
}

.topnav-right {
    color: seashell;
    text-align: center;
    float: right;
    padding: 0 15px;
    height: 69px;
    margin-top: 17px;
}

.topnav {
    display: inline-block;
    height: 69px;
    width: 200px;
    position: relative;
}

.topnav img {
    max-height: 50px;
    max-width: 200px;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}

/* --------------------------------------- */

.background {
    background-image: url(https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-mission-background.jpg);
    height: 700px;
    width: 1200px;
    position: relative;
    margin: 0 auto;
    top: 69px;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

.background h2,
.background h4 {
    text-align: center;
    background-color: black;
    width: 100%;
}

.background h2 {
    padding-top: 20px;
}
.background h4 {
    padding-bottom: 20px;
}

/* -------------------------------------------- */

.monthlyImages {
    width: 1000px;
    margin: 0 auto;
    text-align: center;
    display: inline-flex;
    position: relative;
    top: 100px;
    justify-content: center;    
    flex-wrap: wrap;

}
    
    .monthlyImages Img {
    width: 300px;
    height: 200px;
    margin-right: 10px;
    display: inline;
    }
    
    figcaption.caption {
    display: inline-flex;
    text-align: center;
    margin-top: 27%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    right: 25%;
    }

    /* Texten */

    .monthlyTea {
        width: 1000px;
        position: relative;
        margin: 0 auto;
        top: 90px;
        display: flex;
        justify-content: center;
        flex-direction: column;
        line-height: 50px;
    }

    .monthlyTea h2,
    .monthlyTea h4 {
        text-align: center;
    }

Updated Html (Not much changed)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Tea Cozy</title>
  <link href="./css/styles.css" rel="stylesheet" type="text/css">
</head>
<body>

  <header>
    <div class="topnav">
      <img class="logo" src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-tea-cozy-logo.png">
    </div>
    <div class="topnav-right">
      <a href="#home">Home</a>
      <a href="#featured-tea">Featured Tea</a>
      <a href="#locations">Locations</a>
    </div>
  </header>


  <div class="background"> 
    <h2>Our Mission</h2>
    <h4>Handpicked, Artisanally Curated, Free Rangem Sustainable, Small Batch, Fair Trade, Organic Tea</h4>
  </div>


  <!-- Tea images title -->
  <div class="monthlyTea">
    <h2>Tea of the month</h2>
    <h4>What's Steeping at The Tea Cozy?</h4>
  </div>

  <div class="monthlyImages">
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-berryblitz.jpg"></figure>
   <figcaption class="caption">Berry Blitz Tea</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-spiced-rum.jpg"></figure>
    <figcaption class="caption">Spiced Rum</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-donut.jpg"></figure>
    <figcaption class="caption">Donut</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-myrtle-ave.jpg"></figure>
    <figcaption class="caption">Myrtle Ave</figcaption>
    <figure><img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-bedford-bizarre.jpg"></figure>
    <figcaption class="caption">Bedford Bizarre</figcaption>
  </div>

</body>
</html>

Any clue on how to fix this?

Thanks for the help!

I managed to get it to work with this CSS Code:

.monthlyImages {

        display: flex;

        justify-content: center;

        flex-wrap: wrap;

        position: relative;

        top: 90px;

    }

    .item {

        padding: 5px;

    }

    .item img {

        height: 200px;

        margin: 10px;

        display: block;

    }

    .item span {

        display: block;

        padding: 5px;

        font-weight: bold;

        text-align: center;

    }

And this HTML

 <div class="monthlyImages">
    <div class="item">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-berryblitz.jpg">
    <span>Berry Blitz Tea</span>
    </div>

    <div class="item">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-spiced-rum.jpg">
    <span >Spiced Rum Tea</span>
    </div>

    <div class="item">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-donut.jpg">
    <span>Donut</span>
    </div>

    <div class="item">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-myrtle-ave.jpg">
    <span>Myrtle Ave</span>
    </div>

    <div class="item">
    <img src="https://s3.amazonaws.com/codecademy-content/courses/freelance-1/unit-4/img-bedford-bizarre.jpg">
    <span>Bedford Bizarre</span>
     </div>
  </div>

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.