Reputation: 53
I'm using Bootstrap to display the checkboxes in two columns. Short example:
<fieldset class="col-lg-6 col-md-12">
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</fieldset>
Here is an image of the checkboxes in two columns In the image you can see the "transportation" checkbox dropping much lower than the other checkboxes.
How can I prevent the empty space between the checkboxes, in certain screen sizes? I can't change the way I'm displaying the label and the span inside it, but I can add classes to them.
Upvotes: 3
Views: 8177
Reputation: 96
You just have to add this CSS:
ul {
column-count: 2;
column-gap: 2rem;
list-style: none;
}
Made some changes in your HTML
<div class = "container">
<div class="row">
<div class="col-12">
<ul>
<li>
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</li>
<li>
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</li>
<li>
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</li>
<li>
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</li>
<li>
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</li>
</ul>
</div>
</div>
</div>
Upvotes: 6
Reputation: 309
You need to make your divs allign in a row like this:
<div class = "container">
<div class="row">
<fieldset class="col-sm-6">
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</fieldset>
<fieldset class="col-sm-6">
<label>
<input type="checkbox" />
<span>Here is the text</span>
</label>
</fieldset>
</div>
</div>
Upvotes: 0