How to align two <select> elements side by side using Bootstrap

The issue I am encountering is that these two select elements within the same control-group are being displayed vertically when I want them to be displayed horizontally. I attempted using inline-block in CSS, but there are other <div> elements with the same control-group class that have different width and margin settings. Changing the class name did not resolve the issue either.

<div class="control-group">
     <label for="week">Dispatch schedule:</label>

    <select class="form-control" name="week" id="week" title="Delivery" style="width:110px;">


      <option data-val='OPEN' value="READY">Ready</option>


      <option data-val='CLOSE' value="1st WEEK">1st Week</option>

      <option data-val='CLOSE' value="2nd WEEK">2nd Week</option>

       <option data-val='CLOSE' value="3rd WEEK">3rd Week</option>


    </select>


        <select name="Delivery" id="Delivery" disabled="">

        <option value="OPEN">Open</option>
      <option value="CLOSE">Close</option>
    </select>

        <script>
                                var category = document.getElementById('Delivery');
    document.getElementById('week').onchange = function() {
      var optionSelected = this.options[this.selectedIndex];
      if (optionSelected.textContent != '-') {
        if (optionSelected.dataset.val === 'OPEN') {
          category.value = 'OPEN';
        } else {
          category.value = 'CLOSE';
        }
      } else {
        category.value = '';
      }
    }

                                </script>

                                </div>

Answer №1

Flexbox layout example:

<div class="control-group">
     <label for="week">Dispatch schedule:</label>
      <div style="display: flex; flex-direction: row;">
         <select></select>
         <select></select>
      </div>
</div>

Bootstrap design demo:

<div class="control-group">
     <label for="week">Dispatch schedule:</label>
      <div class="row>
         <div class="col-md-6>
             <select></select>
         </div>
         <div class="col-md-6>
              <select></select>
         </div>
      </div>
</div>

CSS styling version:

<div class="control-group">
     <label for="week" style="display: block; width: 100%;">Dispatch schedule:</label>
     <select style="display: float: width: 49%;></select>
     <select style="display: float: width: 49%;></select> 
</div>

Answer №2

Utilizing a multi-column grid system allows you to set the number of columns or width as needed.

Check out the example on jsfiddle - here

**

<div class="control-group">



<div class="row">
  <div class="border col-xs-4"><label for="week">Dispatch schedule:</label></div>
  <div class="border col-xs-4"><select class="form-control" name="week" id="week" title="Delivery" style="width:110px;">


      <option data-val='OPEN' value="READY">Ready</option>


      <option data-val='CLOSE' value="1st WEEK">1st Week</option>

      <option data-val='CLOSE' value="2nd WEEK">2nd Week</option>

       <option data-val='CLOSE' value="3rd WEEK">3rd Week</option>


    </select>
</div>
  <div class="border col-xs-4">  <select class="form-control" name="Delivery" id="Delivery" disabled="" style="width:110px;">

        <option value="OPEN">Open</option>
      <option value="CLOSE">Close</option>
    </select></div>
</div>

</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

Incorporating JavaScript/jQuery values into C# backend with ASP.NET

Despite attempting all possible methods, I am unable to pass the screen.width value from a JS script on an aspx page to C# in the code behind. Even though the screen.width is correctly assigned, it never gets passed to my hidden field value. <asp:Conte ...

Registration of Laravel Vue.js components

I am currently working on a Vue.js application in conjunction with Laravel. To get started, I registered Vue.js like this: import Vue from 'vue'; import VueRouter from 'vue-router'; Vue.use(VueRouter); import App from './compone ...

Error in Adding Items to React To-Do List

As I work on creating a React todo app following a tutorial, I have encountered an issue. Despite having components and context files set up, the addItem function does not render the item and date into the todo list when the 'Add todo' button is ...

Disabling specific time slots in the mat select functionality

I have a scenario where I need to display time slots at 30-minute intervals using Mat Select. export const TIME=["12:00 AM","12:30 AM","01:00 AM","01:30 AM","02:00 AM","02:30 AM","03:00 AM&qu ...

What is the equivalent of {...props} in React for destructuring props in Vue?

When working in React, I can destructure props with ease: function MyComponent() { const myProp = { cx: '50%', cy: '50%', r: '45%', 'stroke-width': '10%' } return ( <svg> ...

I am looking to manage user-related data in the comment model using mongoose and express

I have a user, post, and comment modal This is my comment modal import mongoose from "mongoose"; const CommentSchema = new mongoose.Schema({ postId: { type: mongoose.Schema.Types.ObjectId, ref: "Post", }, userId: { t ...

Sending form data to the server using JavaScript: A step-by-step guide

Currently, I am dealing with the configuration of two servers. One server is running on React at address http://localhost:3000/contact, while the other is powered by Express at address http://localhost:5000/. My goal is to transmit form data as an object v ...

Creating a tree-like design with the spry accordion換stepping up your spr

I want to style my accordion in a way that it resembles a tree structure. How can I achieve this using CSS? For example: + should be displayed when the accordion tab is closed, and - when the accordion is open. <div class="Accordion" id="systemAccordi ...

Eliminate a specific element from the dataset

My question revolves around a data array used to populate three drop down <select> boxes. How can I eliminate duplicate values within the drop downs without affecting the array itself? For example: data = { firstbox_a: ['grpA_1','gr ...

steps to remove the border of the select box in MUI component

i am struggling to disable the border on the select box and change the color of the label text when focused or blurred i have attempted it but have been unsuccessful i am not very skilled at Mui component customization this is the image that i desire ht ...

Unable to store loop information fetched from api into a JSON file

I'm currently facing an issue with my code where I am trying to save the results from looping through an API into a JSON file using writeFileSync. Here is the code snippet in question: function processRarity(limit) { var resultJson = []; for ( ...

Saving a variable's value using Knockout loop within an HTML document

As a newcomer to KO, I have been utilizing the following code in my HTML file to print a specific value: <!-- ko foreach: { data: JSON.parse($parent.options), as: 'option' } --> <!-- ko if: option.label === 'AAA' || option. ...

Tips for updating the CSS properties of the "html" element

html { width:100%; } Looking to dynamically update the CSS of the html tag upon button click using JavaScript. The goal is to modify the existing HTML CSS code as shown below, but achieving this dynamically with a script. Is it possible? html { w ...

Javascript eval function providing inaccurate results

I have encountered a problem while using eval() for a calculator I am developing. When I input the following code: console.log(eval("5.2-5")); The output is: 0.20000000000000018 I am confused as to why this is happening. Thank you for your assistance. ...

To enable the description p tag only when the search box text matches the search criteria, otherwise keep the p tag disabled

I need to develop a search feature that includes a search box, a heading, and a paragraph description. Initially, the description should be hidden, but when a user enters text that matches the description, the paragraph tag should become visible. An exampl ...

What is the best way to initially hide a div using slide toggle and then reveal it upon clicking?

Is there a way to initially hide the div tag and then animate it in a slide toggle effect? I attempted using display:none on my '.accordion_box' followed by show() in slideToggle, but this results in adding the CSS property display: block. My goa ...

Eliminate duplicated partial objects within a nested array of objects in TypeScript/JavaScript

I'm dealing with a nested array of objects structured like this: const nestedArray = [ [{ id: 1 }, { id: 2 }, { id: 3 }], [{ id: 1 }, { id: 2 }], [{ id: 4 }, { id: 5 }, { id: 6 }], ] In the case where objects with id 1 and 2 are already grou ...

What is the process for executing JavaScript code that is stored as a string?

After making an AJAX call, I receive a random string (constructed dynamically on the server) that contains JavaScript code like: Plugins.add('test', function() { return { html: '<div>test</div&g ...

Typescript: Add a new variable preceding a specified string

fetchArticle(articleId: string): Observable<any> { return this._http.get(`${this._url}/${articleId}`) .map((response: Response) => response.json()) .do(value => console.log(value)) .catch((error) => Observable.throw(err ...

Having trouble getting Material-UI radio buttons to cooperate with react-final-form

After successfully implementing my material-ui radio button, I encountered issues when integrating it with react-final-form. The problem now is that the radio button is no longer clickable. However, upon removing the ...input inside inputProps, the radio b ...