Inline Bootstrap 4 checkboxes and dropdowns

Currently working in Bootstrap 4, I have a requirement to incorporate a checkbox and a dropdown menu side by side within a div. The checkbox should be positioned before the dropdown.

For reference, an image depicting the desired layout can be viewed below:

Example image:

https://i.sstatic.net/inp8p.png

Any suggestions on how I can achieve this using Bootstrap 4?

Answer №1

To achieve this, you can utilize either bootstrap's Inline forms or Column Auto Sizing. Below are two examples of code snippets for your reference.

Using Inline forms:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<div class="form-inline">
      <div class="custom-control custom-checkbox mr-sm-2">
        <input id="workflow" name="workflow" class="custom-control-input" type="checkbox">
        <label class="custom-control-label" for="workflow">Default Workflow</label>
      </div>
      <select id="dropdown" name="dropdown" class="custom-select" >
        <option value="Option 1">Option 1</option>
        <option value="Option 2">Option 2</option>
        <option value="Option 3">Option 3</option>
      </select>
    </div>

Using Column Auto Sizing:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <div class="form-row align-items-center">
  <div class="col-auto">
    <div class="custom-control custom-checkbox">
      <input id="workflow" name="workflow" class="custom-control-input" type="checkbox">
      <label class="custom-control-label" for="workflow">Default Workflow</label>
    </div>
  </div>
  <div class="col-auto">
    <select id="dropdown" name="dropdown" class="custom-select">
      <option value="Option 1">Option 1</option>
      <option value="Option 2">Option 2</option>
      <option value="Option 3">Option 3</option>
    </select>
  </div>
</div>

Answer №2

Avoid using bootstrap classes here

.custom-input-wrapper {
  display: flex;
}

label {
  margin-right: 10px;
}
<div class="custom-input-wrapper">
  <input type="checkbox" name="checkbox" id="checkbox">
  <label for="checkbox">Default workflow</label>
  <select name="select" id="select">
    <option value="option1">option1</option>
    <option value="option2">option2</option>
    <option value="option3">option3</option>

  </select>
</div>

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

Customize the default getstream component styles in a NextJS Component

Is there a way to customize the CSS of getStream.io components using custom CSS? I have created a component as shown below and now I want to override the styles for various classes of its components. Following the instructions in this README file, I impor ...

Angular 8: Form Input Field Alignment Issue

In my form, I have a total of 4 fields with two fields in each row. The problem arises when the title of one field is very long, causing that particular field to shift downwards and resulting in misalignment within the form structure. For example: Very lon ...

Combining multiple images into one CSS image sprite to create 4 clickable

Could someone please review this segment of the CSS to ensure its accuracy? CSS #nav-list { list-style-type: none; background-repeat: no-repeat; background-image:url("../_img/Footersprite.png") } #nav-list li, #nav-footer a { height: 40 ...

Angular animation not firing on exit

I am encountering an issue with my tooltip component's animations. The ":enter" animation is working as expected, but the ":leave" animation never seems to trigger. For reference, here is a link to stackblitz: https://stackblitz.com/edit/building-too ...

Arrange four Divs next to each other with flexbox styling

I've been struggling with aligning my cards side by side. They are a series of divs nested in lists under a <ul> Changing the positioning is not resolving the issue, and I'm hesitant to alter the display as it's crucial for responsive ...

Image Width in Firefox Parent Element Exceeds Limits

When using a responsive picture element, the parent element does not receive the correct width in Firefox on OS-X. Are there any solutions or workarounds for this issue? .picture-wrapper { float: left; } .next-element { float: left; } < ...

aligning columns within a flexible element that has a maximum height

Within this flex element, I have set flex: column wrap; and max-height: 150px;. The issue I'm facing is that justify-content doesn't seem to be working. However, when I switch to using height: 150px, the alignment works fine. This problem arises ...

"Although disabled, input elements can still be focused on in Firefox browser

Illustrative example let userInput = document.createElement("input"); userInput.id = "user-input"; userInput.type = "number"; userInput.className = "user-number-input"; userInput.disabled = true; document.body.appendChild(userInput); .number-inp ...

Is there a substitute for using CSS divs with display:table?

<div id="wr"> <div id="con"> <div id="unknownWidth">some box with unknown width</div> </div> <div id="knownWidth"></div> </div> #wr { width:300px; height:100px; border:1px sol ...

Tips for locking the position of a table header and allowing only the table body to scroll

I have designed a table with tbody consisting of 2 tr elements. One tr is used for hiding/showing data. I am trying to keep the Table header fixed while only scrolling the table body. However, as I am using angular js ng-repeat on the tbody, I am encounte ...

Integrate XML information into a webpage's table layout

I am currently working on integrating an XML file into my HTML and displaying it in a table. A snippet of the XML is provided below: <?xml version="1.0" encoding="UTF-8"?> <product category="DSLR" sub-category="Camera Bundles"> <id>0 ...

Issues with alignment in Firefox

My table alignment is off in Firefox but looks fine in Chrome and IE. Do I need to add an "FF Fix" for this issue? In Chrome/IE, the little dot in the bottom right corner of each cell appears correctly, but in Firefox it seems to be misplaced in the top r ...

Clicking anywhere outside sidepanel does not cause it to disappear

I am currently working on the website alpha.dubaiexporters.com. http://alpha.dubaiexporters.com/aboutus.aspx When I resize the browser, a blue button panel appears which, upon clicking, reveals the navigation side bar. However, the issue is that it does ...

Problem with items overlapping in hoverable drop-down menu

I have been attempting to create a hoverable dropdown menu, but I am encountering an issue where the items of the dropdown are overlapping. Despite my efforts to adjust the CSS classes, I have not been successful in fixing this problem. Additionally, I ha ...

Attempting to open and display the contents of a text file (.txt) within a modal dialog box upon clicking a button

I am attempting to develop a modal that will appear when the user clicks on a specific button. The goal is for this modal to showcase text retrieved from a separate file stored on the server. My aim is to show this text within a dialog box modal. So far, ...

Do specific elements of typography adjust according to the size of the window?

I'm always amazed by the creative solutions that come out of this community. So I'm reaching out to see if anyone knows a way to achieve something unique with CSS! Specifically, I'm curious if it's possible to make certain horizontal p ...

I'm having trouble showing the concealed list with JavaScript

I am new to javascript and facing a challenge. Whenever I update the list items in an HTML example from engineer, pilot, technician, if I select engineer, there should be an onchange event calling a function in JavaScript that shows a hidden select list co ...

Issue with sticky navbar becoming glitchy and shaky when resized while scrolling in Bootstrap

Attempting to make the navbar shrink and change color gradually upon scrolling, I added a transition CSS property to achieve this effect. However, during testing, I encountered a serious glitch where the navbar starts shaking violently up and down at a ce ...

Modify the color of the table map based on specific conditions in a React.js application

To modify the table entry's color based on the current balance, follow these conditions: If the current balance is less than 100, it should be shown in red. If the current balance is between 100 and 200, display it in yellow. Otherwise, show it in gre ...

Troubleshooting Issue with jQuery replaceWith in Loop

Trying to make it so that when the update button is clicked, the text on the left side becomes an input box: Click the update button and the text on the left will be an input box However, instead of just one input box appearing, all the text on the left s ...