0

I'm using bootstrap to split my blog's homepage posts into 2 columns. In order to avoid one issue (posts badly displayed due to different height, see example here:

enter image description here

I'm defining the article height to 350 pixels (and here you can see it solved:

enter image description here

The problem is this solution causes posts to be displayed one over the other, when visitors are using a small screen (mobile or small tablets).

So I'm currently using a javascript to avoid this, but I think it's not the best solution. Do you know if there's a better CSS method to obtain this same result? (I'm newbie)

Index:

<article class="post col-md-6 main article" id="DeviceScreen">

CSS:

#namisboobs{height:350px;}
#anasboobs{height:auto;}

Header:

<script>
  var el = document.getElementById('DeviceScreen');
    {
    if ($(window).width() < 960)
    { el.innerHTML = (('anasboobs'));
    }
    else { el.innerHTML = 'namisboobs';}
    }
</script>

 

MaxiGui
  • 6,190
  • 4
  • 16
  • 33
D. Dragon
  • 13
  • 3

1 Answers1

0

You can do like this.

.post {
  background-color: green;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<div class="d-flex flex-wrap justify-content-center">
  <div class="align-self-stretch col-md-6 col-12 post">
    This is sample text.
  </div>
  <div class="align-self-stretch col-md-6 col-12 post">
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.<br>
    This is sample text.
  </div>
</div>
Sato Takeru
  • 1,092
  • 1
  • 5
  • 16