Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Put images next to each other using CSS

I am currently working on an assignment and ran into a bit of a problem. I am trying to put images next to each other using CSS. But it does not seem to work. I am using semantic HTML, which means for the two images I am using the <figure> tag. I will show example of the code I have:

.blitz {
  height: 200px;
  width: 300px;
  float: left;
}

figcaption {
  font-family: Helvetica;
  font-size: 22px;
  color: gray;
}

.rum {
  height: 200px;
  width: 300px;
}
<figure>
  <img class="blitz" src="https://content.codecademy.com/courses/freelance-1/unit-4/img-berryblitz.jpg" alt="Berry Blitz">
  <figcaption>Fall Berry Blitz Tea</figcaption>
</figure>
<figure>
  <img class="rum" src="https://content.codecademy.com/courses/freelance-1/unit-4/img-spiced-rum.jpg" alt="Spiced Rum">
  <figcaption>Spiced Rum Teat</figcaption>
</figure>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Wrap your figure elements inside of a div and set that to display as flex. See below:

div {
  display:flex;
}
img {
  max-width:200px;
}
<div>
  <figure>
    <img class= "blitz" src="https://content.codecademy.com/courses/freelance-1/unit-4/img-berryblitz.jpg" alt="Berry Blitz">
    <figcaption>Fall Berry Blitz Tea</figcaption>
  </figure>
  <figure>
    <img class="rum" src="https://content.codecademy.com/courses/freelance-1/unit-4/img-spiced-rum.jpg" alt="Spiced Rum">
    <figcaption>Spiced Rum Teat</figcaption>
  </figure>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading