-1

I have to make a testimonial section where I want to show divs stacked vertically in two coloumns. Please chedck the code below. I get the results quite close but since divs are assigned float property they don't tolerate the next div just after it and are printed with unwanted space.

Please check the URL given. https://codepen.io/parvezdgn/pen/oNNXevL

Below is the markup and CSS, I am using:

body {
  font: normal 12px 'arial'
}

.container {
  width: 70%;
  margin: 0 auto;
}

.testimony-item {
  width: 50%;
  float: left;
}

.testimony {
  margin: 0 20px 25px;
  border-bottom: 2px solid #ff2b58;
  padding-bottom: 20px;
}

.testimony strong {
  display: block;
}

.stu-details {
  padding: 15px;
  background: #ddd;
  position: relative;
  margin-top: 20px;
}

.stu-details i {
  position: absolute;
  top: -45px;
  right: 15px;
}
<div class="container">
  <div class="testimony-item">
    <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
  </div>
  <div class="testimony-item">
    <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
  </div>
  <div class="testimony-item">
    <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
  </div>
</div>

What changes do I need to do to fix it?

Thanks, P

Rahul Soni
  • 153
  • 3
  • 18
  • You either go with CSS columns, or you will need some scripting solution such as masonry.js. – 04FS Oct 09 '19 at 09:25

1 Answers1

0

If I understood true, maybe like this ??

Using FlexBox .

    body{font:normal 12px 'arial'}
.container{width:70%; margin: 0 auto;display: flex; flex-direction:row; flex-wrap: wrap; align-items: flex-end;}
.testimony-item{flex-basis:50%; box-sizing: border-box;}
.testimony{margin:0 20px 25px; border-bottom:2px solid #ff2b58; padding-bottom:20px;}
.testimony strong{display: block;}
.stu-details{padding:15px; background: #ddd; position:relative; margin-top: 20px;}
.stu-details i{position:absolute; top:-45px; right:15px;}

    
<div class="container">
    <div class="testimony-item">
        <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
    </div>
    <div class="testimony-item">
      <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
    </div>
    <div class="testimony-item">
      <div class="testimony">
      <p>text</p>
      <div class="stu-details">
        <strong>text</strong>
        <small>text</small>
      </div>
    </div>
    </div>
</div>
dnaz
  • 276
  • 5
  • 14
  • Thanks, Ramazan! I am sorry but I don't think I have been able to frame my problem correctly. The issue is I don't want these boxes to be equal height. They should take the height as per the content inside them. There should not be blank spaces between them. – Parvez A. Oct 09 '19 at 09:18