Inline form in Bootstrap causes line break when including input and button elements

While I have been utilizing Bootstrap for quite some time now, I wouldn't consider myself an expert, but rather proficient. However, I've hit a roadblock with this form-inline issue:

It seems like a simple task - trying to align two elements in a row, yet here I am struggling:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
<div class="row">
<div class="col-xs-6">
  <form class="form-inline">
    <div class="form-group">
      <label for="modal_add_group_input"></label>
      <input class="form-control" id="modal_add_group_input" placeholder="Nombre de grupo" type="text">
    </div>
    <button type="submit" class="btn btn-success">
        <span style="color: white;" class="glyphicon glyphicon-plus-sign">      
        </span> Crear Grupo</button>
    </form>
</div>
</div>
</div>

Just sticking to the basics here, and even the provided example doesn't seem to be working:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<form class="form-inline">
  <div class="form-group">
    <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
    <div class="input-group">
      <div class="input-group-addon">$</div>
      <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
      <div class="input-group-addon">.00</div>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Transfer cash</button>
</form>

Any suggestions on what could be going wrong? Ç_Ç

PS: This is not a duplicate of Bootstrap inline form's submit button not in the same line. I tried that solution as well, but it didn't work.

Answer №1

It seems that the issue in the code snippet is caused by the breakpoint, where the form-group component spans 100% width. Are you looking to keep it on the same line for mobile devices?

Here are three possible solutions:

  1. Inline layout for larger screens
  2. Inline layout for all screen sizes
  3. Inline layout for all screen sizes without using grid (updated answer)

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> **Inline layout for larger screens**
<form class="form-inline">
  <div class="form-group">
    <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
    <div class="input-group">
      <div class="input-group-addon">$</div>
      <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
      <div class="input-group-addon">.00</div>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Transfer cash</button>
</form>
<hr> **Inline layout for all screen sizes**
<form class="form-horizontal">
  <div class="form-group">
    <div class="col-xs-6">
      <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
      <div class="input-group">
        <div class="input-group-addon">$</div>
        <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
        <div class="input-group-addon">.00</div>
      </div>
    </div>
    <div class="col-xs-6">
      <button type="submit" class="btn btn-primary">Transfer cash</button>
    </div>
  </div>
</form>

<hr>
<div class="container">
  **Inline layout for all screen sizes without using grid**
  <div class="row">

    <div class="col-xs-6">
      <form>
        <div class="pull-right">
          <button type="submit" class="btn btn-primary">Transfer cash</button>
        </div>
        <div class="">
          <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
          <div class="input-group">
            <div class="input-group-addon">$</div>
            <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
            <div class="input-group-addon">.00</div>
          </div>
        </div>
      </form>
    </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

What is the process for adjusting the checkbox border color in Material Design 15 and above?

Ever since the latest update to Angular Material 15, I've noticed some changes in how styling is applied to Angular Material components. Previously, in version 14, I used to be able to accomplish styling changes with code like this: ::ng-deep .mat-che ...

Issue with the Textualizer effect in HTML not functioning properly

Having trouble with the textualizer effect - my screen is just blank. I've tried copying it from this source: . Inserted it into both visual studio and notepad, but still no success! <html> <head> <title></title> <script sr ...

Tips for shifting an image upwards and extending it beyond one section while keeping the other section unaffected

Struggling all day while designing a CSS site, trying to hide one part of an image when it overflows and keep another part visible, in addition to moving the image up and down. Here's the HTML code snippet: <section class="next-gen"&g ...

Customizing the active link color in Bootstrap dropdown menus

Is there a way to customize the color and background of an active link in a boostrap's dropdown menu? Despite trying to override bootstrap's @dropdownLinkColorActive and @dropdownLinkBackgroundActive variables, the changes don't seem to tak ...

Implementing dynamic content loading using CSS and jQuery upon link/button activation

I'm facing an issue where I am attempting to align content to the left side of my screen to display a feed while also ensuring that the pushed content is responsive. Unfortunately, the feed is not visible and the content remains unresponsive. Is ther ...

Form calculation

An issue has arisen with my calculating form for a client where an incorrect amount is displayed when 0.93 is entered into the percentage box. Original calculation: 10 x 10 x 15 x 0.93 = 13.95 Corrected calculation: 10 x 10 x 15 x 0.93 = 1.395 I am seek ...

What's the best way to create a responsive design for two buttons?

I am utilizing Bootstrap to create two buttons on my webpage that will stack vertically instead of horizontally when the screen width decreases. I attempted to achieve this using the following code: index.php: <div class="container-fluid"> ...

Extract JSON data from Python API

Currently, I am delving into web programming and have created a Python API that queries an SQL database to return a JSON. The functionality of the API is as expected. In parallel, I've developed a controller where I execute a GET request to utilize t ...

This code is only functional on JSFiddle platform

I encountered an issue with my code recently. It seems to only work properly when tested on jsfiddle, and I can't figure out why it's not functioning correctly on codepen or when run from local files. Why is this code specific to jsfiddle? When ...

A guide on dynamically generating Bootstrap rows and columns using an ngFor loop

Receiving data from the backend with a number of maps, I need to display them on the page. The placement of the maps is based on even and odd conditions. (For example, if there is only one map, it should occupy the entire page. If there are two maps, they ...

What is the best way to create this menu using a CSS pseudo-class selector?

I have created a menu and now I want to enhance its functionality by adding keyboard support. My goal is to make the menu accessible using keyboard keys, such as pressing Enter to show the menu, Tab to navigate through menu items, and ESC to hide the menu. ...

Stop child elements from spilling out of the parent container without using fixed height measurements

I am in the process of creating an angular component with a header, buttons, a table, more buttons, and a footer. However, I am facing some challenges with the layout. <my-component> <div>Header Section</div> <some-stuff class=&quo ...

Title with lower border shorter than width

Looking to achieve an underline effect with a bottom border that is narrower than the width of the h2 title. Though I typically avoid uploading images, here is one to provide further clarification of my question: ...

Steps to dynamically display or conceal a DIV using Bootstrap 5

I am facing an issue with a navbar that has buttons to reveal hidden divs underneath. <a data-bs-toggle="offcanvas" href="#select" role="button" aria-controls="select"></a> <div id="select" c ...

Conceal the message "Table does not contain any data" if data exists in the table

This table is populated with data retrieved via JSON. Here is the structure: <table id="tblClaimSearch" class="display responsive nowrap" cellspacing="0" width="100%"> <thead> <tr> <th><input type="checkbox" ...

Chrome browser experiencing issues with setCustomValidity() function

Encountering an issue while attempting to set a custom message in my input field: <b-form-input v-model.number="libpublishingdatefrom" someprops... oninvalid="setCustomValidity(Vue.prototype.trans('validation.gte.numeric'))" class="in ...

When using jQuery, adding a class does not always trigger CSS animation

Currently facing a peculiar issue. I am utilizing jQuery to load articles from JSON and would like to dynamically add a class of 'animate' to each loaded element. $.each(jsonArticles, function (i, article) { var $articleHTML = $( ' ...

Halt the Bootstrap carousel while entering text in a textarea

Is it possible to achieve this? I think so. I have created a carousel with a form inside. The form includes a textarea and a submit button. Currently, the slider does not slide if the mouse pointer is inside it, which is good. However, if the pointer is o ...

Is there a way for the remaining divs in a column to match the width of the widest div?

I'm attempting to ensure that the divs in a column take the width of the widest element, with the exception of the top div which should span 100% of the screen. How can this particular layout be achieved? Please refer to the image below for a clear ex ...

Angular onscroll event creating a parallax effect

I attempted to create a parallax effect using Angular and the OnScroll event, however, while scrolling, the text seems to be flickering. Is there a way to make the smooth rendering onscroll? Maybe through CSS alone? Here is the script I used: https://sta ...