0

I am trying to create something like this:

enter image description here

At the moment I have created this:

* {
  margin: 0px;
  padding: 0px;
  font-family: "Roboto";
}
.wrapper {
  width: 100%;
  max-width: 1000px;
  margin: 0px auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}
.article {
  margin: 10px;
  padding: 10px;
  background-color: orange;
  flex-basis: 200px;
  flex-grow: 1;
}
.productImg {
  display: block;
  height: 100%;
  width: 100%;
}
<div class="wrapper">
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
  <div class="article">
    <img class="productImg" src="https://static.pexels.com/photos/3847/jetty-landing-stage-sea-sky.jpeg" />
  </div>
</div>

Everything works well, but the last .article is sometimes to big. The size should be the same as the .article above him. How can I do this? I've tried it with max- and min-width, but this didn't worked well.

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
MyNewName
  • 1,035
  • 2
  • 18
  • 34

1 Answers1

1

Just try:

.article {
  max-width: calc(50% - 40px);
}

If u cant use calc(), change margin and padding size to procentage

Andrei Fedorov
  • 3,689
  • 2
  • 13
  • 25
  • Thanks for the answer! I combine it with some `media-queries` and then it should be perfect. Thanks alot. – MyNewName Aug 25 '16 at 09:18