0

I have the following code:

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="card">
      <div class="col-md-3" style="display: inline-block; float:left;">
        ... content ...
      </div>

      <div class="col-md-3" style="display: inline-block; float:left;">
        ... content ...
      </div>

      <div class="col-md-3" style="display: inline-block; float:left;">
        ... content ...
      </div>

      <div class="col-md-3" style="display: inline-block; float:left;">
        ... content ...
      </div>
    </div>
  </div>
</div>

These are 4 controls (inputs) and they display fine in desktop and mobile resolution, on desktop they are all next to each other and on mobile they are below each other.

I want it so that on smaller resolutions (mobile) there is 2 next to each other on the first line and 2 next to each other on the second line, but still in larger resolution they should display next to each other on 1 line, this for the purpose of "saving space", the controls don't need to take the complete line on there own because the input is limited.

I have tried but not succeeded to do so by playing with the col-md-x and by having less div's but I can't make it work.

How can I achieve this? Thank you for any direction or suggestion!

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
Dimitri
  • 1,185
  • 2
  • 15
  • 37
  • 1
    `col-md-x` is for medium width displays. If you want other display for different sizes why are you sticking with `md`? Have you read [the documentation](https://getbootstrap.com/docs/4.0/layout/grid/)? – Quentin Mar 11 '20 at 20:16
  • are you trying to make columns inside `
    ` ?!?
    – G-Cyrillus Mar 11 '20 at 20:20
  • @Quentin, I wasn't aware of this, thank you for pointing that out. – Dimitri Mar 11 '20 at 20:22
  • @G-Cyrillus, yes that is correct. What would be a "better" way of doing this and why shouldn't I do it like I am doing? – Dimitri Mar 11 '20 at 20:23
  • 1
    @Dimitri there is no better way, just use the class needed col requires a row ;) . tip was used for the below answer :) Mind the doc and usage, that's the way :) – G-Cyrillus Mar 11 '20 at 20:28

1 Answers1

1

With col-6 on screens smaller than md your col-6 will put this divs 2 per row.I moved the row inside your card class

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
  <div class="container">
 <div class="card">
<div class="row">
   
    <div class="col-6 col-md-3 col-lg-3 co-xl-3">     
     ... content ...
    </div>

    <div class="col-6 col-md-3 col-lg-3 co-xl-3" >                
     ... content ...
    </div>

    <div class="col-6 col-md-3 col-lg-3 co-xl-3" >
    ... content ...
    </div>

    <div class="col-6 col-md-3 col-lg-3 co-xl-3" >
     ... content ...
    </div>
</div>
</div>
Tzimpo
  • 964
  • 1
  • 9
  • 24