0

I have a bunch of cards and I need to make a gallery like in the picture below. Problem is that the sizes of these cards depend on its containing data. They can be small or huge. The whole day I'm trying to make it responsive, could you please help me!!!

enter image description here

.awards-cards {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: repeat(3, 370px);
  grid-auto-rows: minmax(min-content, max-content)
}

.award-card__wrapper {
  max-width: 370px;
  padding: 11px;
  background: #FFFFFF;
  border-radius: 7px;
  height: auto;
  object-fit: cover;
}
<div className="awards-cards">
  <div class="award-card__wrapper"> data inside </div>
  <div class="award-card__wrapper"> data inside </div>
  <div class="award-card__wrapper"> data inside </div>
  <div class="award-card__wrapper"> data inside </div>
  <div class="award-card__wrapper"> data inside </div>
  <div class="award-card__wrapper"> data inside </div>
</div>
m4n0
  • 29,823
  • 27
  • 76
  • 89
Yerlan Yeszhanov
  • 2,149
  • 12
  • 37
  • 67

2 Answers2

0

I have found the solution for this, please find below

CSS for desktop

* {padding:0px; margin:0px;}
*, *::before, *::after { box-sizing: border-box;}
.awards-cards {
  column-count: 4;
  column-gap: 1em;
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px;}
.award-card__wrapper {
  background-color: #eee;
  display: inline-block;
  margin: 0 0 1em;
  width: 100%;
  padding: 25px;
}

CSS for Mobile

@media (max-width: 767px) {
  .awards-cards{ column-count: 2;}
}

HTML structure

<div class="awards-cards">
  <div class="award-card__wrapper"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
 </div>
  <div class="award-card__wrapper"> It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, </div>
  <div class="award-card__wrapper"> Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. </div>
  <div class="award-card__wrapper"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in </div>
  <div class="award-card__wrapper">  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div>
  <div class="award-card__wrapper"> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. </div>
</div>
jqueryHub
  • 209
  • 2
  • 15
0

I've done a fiddle , check this https://jsfiddle.net/5p9bnx7L/


    .awards-cards {
      column-count: 4;
      column-gap: 1em;

    }

    .award-card__wrapper {
      background-color: #eee;
      display: inline-block;
      margin: 0 0 1em;
      width: 100%;
    }


    @media only screen and (max-width: 480px) {
    .awards-cards {
      column-count: 3;
      column-gap: 1em;
    }
    }

red
  • 1,529
  • 1
  • 12
  • 33