Home > Software design >  Need to make responsive card, 4 to be showed on desktop and 2 in mobile
Need to make responsive card, 4 to be showed on desktop and 2 in mobile

Time:11-16

I am creating a website, i am beginner in web design i want to create a design of category to be showed 4 cards in desktop and 2 card in mobile view.

My code below

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI N" crossorigin="anonymous">

<div >
  <div >
    <br>
    <div >Categories</div>
    <br>
    <div >
      <div >
        <div >
          <div >
            <div > <img src="#" alt=""> </div>
            <div > <b>Public Speech</b>
              <a href="#">
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <br> Categories
  <br>

I tried a lot of changes but didn't get what i want. I expect from developers to help in this.

CodePudding user response:

You have 12 columns by default.

You can write something like this <div >

12/3 = 4 in a row when screen is xl
12/4 = 3 in a row when screen is lg
12/6 = 2 in a row when screen is md
12/12= 1 in a row when screen is sm

You can customize the columns depending on the devices as you want. :)

CodePudding user response:

Refering to bootstrap documentation, max columns numbers are 12. So you need to make col-6 col-6 for mobile (will make 2 columns (12/2 = 6)) and for desktop col-3 col-3 col-3 col-3 (will make 4 columns (12/4 = 3)).

See simplified example below:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI N" crossorigin="anonymous">

    <div >
      <div >
        <div >
           1
        </div>
      </div>
      <div >
        <div >
           2
        </div>
      </div>
      <div >
        <div >
           3
        </div>
      </div>
      <div >
        <div >
           4
        </div>
      </div>
    </div>

  • Related