Using Twitter Bootstrap classes and spans within a control-group element

I'm working on creating a user-friendly interface that includes a group of checkboxes displayed as buttons. My goal is to organize these buttons into groups with a maximum of 3 buttons per row.

<div class="container">
  <div class="control-group">
    <p class="pull-left"><label class="control-label" for="Languages">Languages</label></p>
    <div class="controls">
      <div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
        <input type="checkbox" value="1" id="Languages_0" name="Languages" checked />
        <label class="btn btn-info btn-small active" for="Languages_0">Italian</label>
        <input type="checkbox" value="2" id="Languages_1" name="Languages" checked />
        <label class="btn btn-info btn-small active" for="Languages_1">French</label>
        <input type="checkbox" value="3" id="Languages_2" name="Languages" checked />
        <label class="btn btn-info btn-small active" for="Languages_2">English</label>
        <input type="checkbox" value="4" id="Languages_3" name="Languages"  />
        <label class="btn btn-info btn-small " for="Languages_3">Spanish</label>
        <input type="checkbox" value="5" id="Languages_4" name="Languages"  />
        <label class="btn btn-info btn-small " for="Languages_4">German</label>
        <input type="checkbox" value="6" id="Languages_5" name="Languages"  />
        <label class="btn btn-info btn-small " for="Languages_5">Portuguese</label>
        <input type="checkbox" value="7" id="Languages_6" name="Languages"  />
        <label class="btn btn-info btn-small " for="Languages_6">Bulgarian</label>
        <input type="checkbox" value="8" id="Languages_7" name="Languages"  />
        <label class="btn btn-info btn-small " for="Languages_7">Latvian</label>
      </div>
    </div>
  </div>
</div>

I attempted to use span3 for layout styling but encountered compatibility issues, particularly with IE. Check out the working example on JSFiddle here.

Answer №1

To organize the checkboxes and labels appropriately, each group of three should be placed within its own div element with the class name controls.

<div class="container">
    <div class="control-group">
        <p class="pull-left">
            <label class="control-label" for="Languages">Languages</label>
        </p>
        <div class="controls">
            <div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
                <input type="checkbox" value="1" id="Languages_0" name="Languages" checked />
                <label class="btn btn-info btn-small active" for="Languages_0">Italian</label>
                <input type="checkbox" value="2" id="Languages_1" name="Languages" checked />
                <label class="btn btn-info btn-small active" for="Languages_1">French</label>
                <input type="checkbox" value="3" id="Languages_2" name="Languages" checked />
                <label class="btn btn-info btn-small active" for="Languages_2">English</label>
            </div>
        </div>
        <div class="controls">
            <div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
                <input type="checkbox" value="4" id="Languages_3" name="Languages" />
                <label class="btn btn-info btn-small " for="Languages_3">Spanish</label>
                <input type="checkbox" value="5" id="Languages_4" name="Languages" />
                <label class="btn btn-info btn-small " for="Languages_4">German</label>
                <input type="checkbox" value="6" id="Languages_5" name="Languages" />
                <label class="btn btn-info btn-small " for="Languages_5">Portuguese</label>
            </div>
        </div>
        <div class="controls">
            <div class="btn-group btn-group-horizontal" data-toggle="buttons-checkbox">
                <input type="checkbox" value="7" id="Languages_6" name="Languages" />
                <label class="btn btn-info btn-small " for="Languages_6">Bulgarian</label>
                <input type="checkbox" value="8" id="Languages_7" name="Languages" />
                <label class="btn btn-info btn-small " for="Languages_7">Latvian</label>
            </div>
        </div>
    </div>
</div>

Check out a demonstration on jsFiddle.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Printed documents fail to display underlined text using Bootstrap styling

Why do the codes show underlines on the webpage but not in the browser's print? This code is from the printOrder.blade.php file: <!DOCTYPE html> <html dir="ltr" lang="en"> <head> <meta charset="UTF-8&qu ...

Utilize AJAX or another advanced technology to refine a pre-existing list

I am trying to implement a searchable list of buttons on my website, but I haven't been able to find a solution that fits exactly what I have in mind. Currently, I have a list of buttons coded as inputs and I want to add a search field that will filte ...

How can you display '<>' characters in a QLabel and set text accordingly?

In my PySide2 (similar to PyQt5) project, I am facing an issue with setting text in a QLabel that includes characters like '<' and '>'. These characters seem to disappear because they are used for font modifications. I have tried ...

Utilizing Tailwind CSS for creating a responsive layout on a Next.js application

I'm just getting started with Tailwind CSS and I decided to build the user interface of my nextjs application using a "mobile first" approach like everyone suggests. I got the flex direction and background color working perfectly on mobile screens, so ...

How can I use jQuery to automatically redirect to a different HTML page after updating a dynamic label?

When I click on a button in first.html, a function is called to update labels in second.html. However, despite being able to see second.html, I am unable to see the updated values in the labels. Can someone please advise me on how to achieve this? functi ...

Set the datepicker with the window positioned to the right side

In my current project, I am utilizing Angular 13, Bootstrap 5, and ngx-bootstrap-fix-datepicker version 5. "bootstrap": "^5.1.3", "ngx-bootstrap": "^8.0.0", "ngx-bootstrap-fix-datepicker": "^5.6.8" ...

Styling with CSS to ensure divs are displayed in two rows

Check out this example I found: https://jsfiddle.net/n3qs0wke/ .wrapper { max-width: 600px; border: 1px solid #333; } .big-div { min-width: 212px; min-height: 212px; max-width: 212px; max-height: 212px; display: inline-flex; ...

What's preventing me from tapping on hyperlinks on my mobile device?

I'm currently working on a website (saulesinterjerai.lt) and everything seems to be functioning properly, except for the fact that on mobile devices, the links aren't clickable and instead navigates to other layers. How can I disable this behavio ...

The error detected in the W3Schools validator pertains to CSS for audio elements that do not contain

Could somebody kindly explain why this code is being flagged as an error on w3schools? audio:not([controls]) { display: none; height: 0; } ...

Border only at the bottom of the outline

I need help creating a bottom outline border when the cursor hovers over an image. I prefer to use this inner border style to avoid any layout issues with a traditional border-bottom. Below is my current code, which includes outline margins: .img-lightbox ...

Issue with Firefox browser: Arrow keys do not function properly for input tags in Twitter Bootstrap drop down menu

Requirement I need to include a login form inside the dropdown menu with username and password fields. Everything is working fine, except for one issue: Issue When typing, I am unable to use the arrow keys (up/down) in Firefox. This functionality works ...

Having trouble with the image resizing in Bootstrap 5 on Safari?

I am facing an issue with a website: There are four images under the section "Serviceangebote" that appear as square icons representing circles. I have no trouble viewing them correctly on Windows (Chrome, Firefox, Edge) and Android devices. The images ar ...

Space around the flex container

I am facing an issue with a flex display that splits the screen into two sections: one for login information and the other for a background picture. When setting up the flex layout, I notice unwanted margins on both sides (highlighted as orange bars in the ...

What is the best way to modify the appearance of the button?

I'm attempting to change the appearance of buttons at the top of a webpage to be square and blue. I have jQuery code for this purpose, but it doesn't seem to be functioning correctly. Here is the snippet of code I am using: $(document).ready(fu ...

Changing Background Color on Div Click

After spending a considerable amount of time on this, I find myself getting confused and stuck. It seems like I might be overlooking something crucial. Essentially, my code is designed to have the default div background (gamebg), and upon clicking one of t ...

Unleashing the Power of Reactstrap: Making Uncontrolled Collapse Panels Open by Default

Can the uncontrolled collapse be displayed as open by default? Below is the standard code for uncontrolled collapse, which is initially shown as a collapsed tab. <Button color="primary" id="toggler"> Toggle </Button> < ...

Utilize Bootstrap to occupy the rest of the available vertical space

Struggling with handling empty space in a Bootstrap grid? Check out the issue I'm facing when the div doesn't fill the entire height. https://i.sstatic.net/zvS7t.png This is the current configuration: <div class="row"> <div class= ...

Different ways to position 3 images side by side and ensure they are centered on the

I am struggling to center 3 images horizontally on my webpage. Despite aligning them in a row, I cannot seem to achieve the desired centering effect. I have tried various methods to center the images, but nothing seems to work effectively. My goal is to ...

What are the steps to insert a plotly graph into a webpage so that it responds to different

I have been working on integrating a plotly pie chart into my website. In order to make the iframe responsive, I decided to utilize this specific tool to generate the necessary html/css. While the chart appears satisfactory on a laptop screen, it is barely ...

Having trouble with the JQuery class selector?

Having a bit of trouble trying to select an element based on its class using $(".class"), and I can't seem to figure out why it's not working. So, the deal is - I have this image element that should appear when a function gets triggered: $("#co ...