Creating inline form groups within a form

Hey there! I'm looking to align the divs with class="form-group" so that their labels are on top, rather than inline with the fields. Currently, they are stacking on top of each other like this:

https://i.sstatic.net/rNoS3.jpg

I want them to appear like this: https://i.sstatic.net/7nXB1.jpg

Below is the code snippet I am working with:

<div class="container">
  <br />
    <div class="row">
        <div class='col-sm-3'>
            <form class="form-inline">
              <div class="form-group">
                <label for="date">DATE</label>
                <div class='col-sm-8 input-group date' id='datetimepicker1'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                </div>
              </div>
              <div class="form-group">
                <label for="date">DATE 2</label>
                <div class='col-sm-8 input-group date' id='datetimepicker1'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                </div>
              </div>
            </form>
        </div>
    </div>
</div>

Answer №1

https://i.sstatic.net/4YHHt.pngMake sure to use the "form-inline" class from Bootstrap for inline forms. It seems like you are already using Bootstrap.

For more information, check out:

https://getbootstrap.com/docs/3.3/css/#forms

I also created a fiddle here:

https://jsfiddle.net/552yzg22/#&togetherjs=O18LSbynLF

Answer №2

Consider the following suggestion:

CSS

.form-group{display: inline-block; }

This action essentially arranges each division with the designation form-group to be displayed in a manner where they align horizontally from left to right. Another alternative is implementing float: left;.

Answer №3

You're going about it the wrong way, here's the correct method:

https://codepen.io/the_leg3nd/pen/rGQKvB?editors=1000

To add multiple rows within the form group itself, there is no need to include any .col-* classes within the form-group or input-group for this scenario.

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

Can you assist me in finding certain Japanese Unicode characters?

I need help finding the Unicode Katakana characters for three Japanese symbols: https://i.sstatic.net/72V5g.png Although I found one of them, the closest matches I could locate are: ⽊ の ⺶ &#12106; &#12398; &#11958; Som ...

Insert a page break after content for desktop browsers

Is it possible to control the display of sections on different screen sizes? I have a page that looks good on 15" laptops, but larger resolutions cause the next section to appear on the first screen. Is there a way to show the next section only on th ...

Styling problem arises on IOS devices due to rounded corners affecting select box

The dropdown menu I am using to "sort products" on our WordPress website is causing some styling issues specifically on IOS devices. I would like the dropdown menu to have rounded corners. It seems to display rounded corners on IOS, but it still shows the ...

What steps should I take to include a Follow - Unfollow Button on my Website?

I need to add a button on my website that allows users to either follow or unfollow a specific game. Here is the table for the follow buttons: Follow Button Table When a user clicks on the button related to the game ID, it should update the game_follow d ...

Mastering the Art of Personalization with Bootstrap 4

My intention is to utilize selected components from Bootstrap 4 for my WordPress theme, which I plan on selling on online marketplaces like Themeforest. However, I do not want to use the entirety of bootstrap.js and all aspects of bootstrap.css. The speci ...

A comprehensive guide on personalizing Bootstrap 4 tooltips to suit your specific needs

I would like to customize the tooltip in Bootstrap 4 based on the screenshot provided below: https://i.stack.imgur.com/wg4Wu.jpg <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta chars ...

Reducing the width of the bootstrap table does not seem to work properly when trying

I am currently working on a bootstrap table design that features a table with a rowspan of "2" in the right corner, creating a layout with 2 rows on one end and another rowspan of "2" on the other end, as shown in the following image: https://i.sstatic.net ...

Split Screen Text Comparisons

For some reason, I am finding it challenging to display two paragraphs side by side without disrupting the overall layout. If you would like a visual explanation of the issue, please check out this video: Video If you're interested in reviewing the c ...

Positioning bar chart columns and text using CSS

My component generates HTML for a simple bar chart, with the height and background color computed within the component. Everything functions correctly, but I am facing an issue where long text causes displacement of the bar above it. Another problem is th ...

Creating a rectangle link that extends beyond its containing div

On our website, there is a button that we are trying to turn into a link without the tape on top of it. The issue we're facing is that creating the link also affects the empty space in the top left corner of the tape graphic. Our Attempts We attemp ...

What is the best method to eliminate excess space between images on a webpage using CSS?

Currently, I am developing a small project just for myself. The main page will consist of multiple images, each spanning the entire page. I am having trouble eliminating this unwanted spacing: https://i.sstatic.net/7eLl5.jpg Your assistance would be gre ...

How to refresh AngularJS controller's JSON object data after making changes to the HTML using a text editor?

Currently, I am working on editing an HTML page that is linked with JSON object data using ng-bind. Interestingly, I have not utilized ng-model in this scenario. The code snippet can be found at the following link: http://plnkr.co/edit/vPYSpOtA96b497iQMHr ...

How to eliminate the vertical scroll indicators in Material UI's TextField

I'm currently working on customizing the styling of a Material UI textfield and I need to remove the top-down arrows. Below is the code snippet I have so far: const theme = createMuiTheme({ MuiInput: { root: { "&::-webkit-outer-spin-bu ...

The script functions perfectly in jsfiddle, yet encounters issues when used in an HTML

I stumbled upon a seemingly peculiar issue with my script in jsfiddle: https://jsfiddle.net/oxw4e5yh/ Interestingly, the same script does not seem to work when embedded in an HTML document: <!DOCTYPE html> <html lang="en"> <head> & ...

When using Italics, the conflict arises between the specified line-height and the actual height of the

Recently, I encountered an issue that has me a bit perplexed: I have a span element with line-height set to 18px and font-size at 16px. Everything works perfectly when the text inside is regular; the height of the span remains at 18 pixels. The problem a ...

Trouble with visibility of Bootstrap navbar collapse button

While creating an application using bootstrap, I encountered a problem with the navigation bar. The issue is that when I resize the page, the links disappear and the toggle button fails to show up. Below is my current navigation bar code: <link rel= ...

What is the best approach to transform an HTML textarea value into JSON format?

Client .. inserting some content into a form <textarea name="data"></textarea> After typing the following data into the textarea: {title: 'Hello one!', author: 'someone'} {title: 'Hello two!', author: 'mygf ...

Troubles with double borders in HTML's opaque border feature

I'm encountering an issue where opaque borders are overlapping each other, causing the alpha value to be twice as high as intended. This problem seems to only affect the first n-1 elements — the last child is rendering correctly. Check out the Cod ...

Insert HTML elements using javascript

Is it possible to change this JavaScript code in the following way: divElement.appendChild(document.createTextNode("<h7>Optie " + inputNumber + ": </h7>")); What would be the best approach to achieve this? ...

What could be causing the span class data to not be retrieved by the getText method

Looking to retrieve the value of a span class called 'spacer-right big project-card-measure-secondary-info' <span class="spacer-right big project-card-measure-secondary-info">1</span> snippet of code: browser.waitForEl ...