Grid box isn't responsive when minimized the screen size

Viewed 52

So I have created this grid box and each box contains a product image, product heading, and little description. The Grid box looks fine in normal desktop screen size but when minimized it doesn't look good. I have tried media query and width, margin-right but it still isn't working. This is the normal window size. I want the box size to set max-width in minimized screen size. enter image description here

This is the minimized size enter image description here

My HTML Code

<div class="row">
    <div class="col-6 col-sm-3 grid-dvr">
        <div class="grid-image"><img src="assets/images/services/dvr/ds-7104hqhi-k1.png" alt=""></div>
        <h5 class="grid-box-heading">DS-7104HQHI-K1</h5>
        <p class="grid-box-description">4-ch 1080p H.265 DVR</p>
    </div>
  
    <div class="col-6 col-sm-3 grid-dvr">.col-6 .col-sm-3</div>

    <!-- Force next columns to break to new line -->
    <div class="w-100"></div>

    <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
    <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
</div>

CSS Code

.grid-dvr {
  margin: 20px;
  border-radius: 5px;
  height: 100px;
  background-color: white;
}

.grid-dvr .grid-image {
  max-width: 150px;
  float: right;
}

.grid-box-heading {
  float: left;
  margin-top: -60px;
}

.grid-box-description {
  font-size: 12px;
  align-items: center;
  margin-top: 40px;
}
1 Answers

You should not use col-6 if you want to make the divs full width in xs size.Instead use col or col-12 instead of col-6

.grid-dvr {
  border-radius: 5px;
  height: 100px;
  background-color: black;
}

.grid-dvr .grid-image {
  max-width: 150px;
  float: right;
}

.grid-box-heading {
  float: left;
  margin-top: -60px;
}

.grid-box-description {
  font-size: 12px;
  align-items: center;
  margin-top: 40px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="row m-2">
  <div class="col col-sm-3 grid-dvr mr-2">
    <div class="grid-image"><img src="assets/images/services/dvr/ds-7104hqhi-k1.png" alt=""></div>
    <h5 class="grid-box-heading">DS-7104HQHI-K1</h5>
    <p class="grid-box-description">4-ch 1080p H.265 DVR</p>
  </div>

  <div class="col col-sm-3 grid-dvr">.col-6 .col-sm-3</div>

  <!-- Force next columns to break to new line -->
  <div class="w-100"></div>

  <div class="col-6 col-sm-3">.col-12 .col-sm-3</div>
  <div class="col-6 col-sm-3">.col-12 .col-sm-3</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

Related