I attempted to position two input blocks side by side, but they are being displayed one on top of

//I have encountered an issue with the HTML code I am using. I am trying to create input buttons in a horizontal layout, but they are not displaying correctly.

<div class="form-row">
    <div class="form-group col-md-5">
      <label for="fname">First name:</label>
      <input type="text" class="form-control" id="fname" placeholder="First name">
    </div>
    <div class="form-group col-md-5">
      <label for="lname">Last name</label>
      <input type="text" class="form-control" id="lname" placeholder="lastname">
    </div>
  </div>

Answer №1

Make sure to include the class "d-flex" in your code.

See below for an example:

 <div class="form-row d-flex">
        <div class="form-group col-md-5">
            <label for="fname">First name:</label>
            <input type="text" class="form-control" id="fname" 
placeholder="First name">
        </div>
        <div class="form-group col-md-5">
            <label for="lname">Last name</label>
            <input type="text" class="form-control" id="lname" 
 placeholder="lastname">
        </div>
    </div>

Answer №2

Creating a space between the two elements can be achieved by using "Justify-Contents-Around"

<div class="form-row d-flex justify-content-around ">
    <div class="form-group col-md-5">
        <label for="fname">First name:</label>
        <input type="text" class="form-control" id="fname" placeholder="First name">
    </div>
    <div class="form-group col-md-5">
        <label for="lname">Last name</label>
        <input type="text" class="form-control" id="lname" placeholder="lastname">
    </div>
</div>

In addition, margin and padding can also be utilized to achieve the desired spacing.

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 could be causing the issue of nth-child blocking the functionality of a:hover styles?

I have a unique collection of images that are styled to resemble polaroid pictures. Each image is given a slight rotation. a.polaroid { transform: rotate(-2deg); } On hover, a scale transformation is applied. a.polaroid:hover { transform: scale(1 ...

Is it required to double click checkboxes to uncheck them?

My checkboxes require 2 clicks to be unchecked, even though one click is enough to check them. This issue occurs in all 7 checkboxes and there is no onchange() function or similar in TS. import { Component, OnInit, Inject } from '@angular/core&apos ...

Exclude specific IDs from Bootstrap 4 scrollspy functionality

I have consecutive sections, and in between them I have an aside without a corresponding anchor. The issue is that the scrollspy is active with the previous section. I want to adjust the scrollspy so that nothing is highlighted as active at that point, and ...

How to allow users to input email text in Django

I have a custom email template that I need help improving: https://i.sstatic.net/RSgLF.png Here is the current template code: <p> Please enter your email: </p> <input id="your_name" type="text" name="your_name" value="{{ mail_content }}"& ...

Alter the background hue of alternate div elements within a row

The table I have contains multiple div elements, each corresponding to an item in an array. Within the table, there is a single tr, and the 1st and 2nd td are not directly related to the 3rd and 4th td. Each td in the table repeats a div element for the ...

Maintain the highlighting of the parent menu item even when hovering over the submenu (HTML/CSS/Jquery)

Having a menu with the potential for subitems, it seems simple enough. The goal is to highlight the parent menu item once the submenu is moused over. Unfortunately, this doesn't happen as expected because the browser reverts back to its default style ...

Issues with AJAX file uploading functionality are preventing users from successfully uploading files

I need help with uploading text files via AJAX on a browser. I have tried implementing the code, but it seems like the file is not being uploaded successfully as var_dump($files) displays array(0). HTML: <form id="uploadsql" action="upload.js" method= ...

Issue with Number Form Input in Firefox on BootstrapVue

I am currently working with BootstrapVue and have a specific input element within a b-form that I need assistance with: <b-form-input v-model="myTest" type="number" max="9999"></b-form-input> My goal is to achieve ...

Warning: An error occurred with undeclared variables... missing variable declaration

Hey everyone, I recently made a post but it seems like my explanation was not clear enough. So here's the issue - I have a products page with a URL structure like http:.......rest_id=3/area='Enfield'. I've been using a similar query on ...

When the button is clicked, HTML buttons toggle and collapse information while toggling all other buttons

As a beginner in HTML and CSS, I've successfully created buttons that display more information when clicked. However, I'm struggling to figure out how to collapse the information being shown by other buttons when a new one is clicked. I've t ...

Every time I click on a section of an HTML webpage, JQuery retrieves the ID of that specific tag

How can I retrieve the id of an Html tag that has been clicked by a user on a web page using Jquery? I have attempted to do this, but it seems to only work for specific tags that are passed in the function. $(document).ready(function(){ $("p").click ...

Getting the value of an HTML tag returned from an Ajax request

After making an AJAX call in VBScript, I am receiving the following HTML: <html> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td width="100%" ...

Best method for reducing spacing between elements in Bootstrap

Utilizing Bootstrap v3 and AdminLTE, I am aiming to reduce the spacing between each content element. Simply adjusting margin-left and margin-right impacts the right margin of the far right content as well as the left margin of the far left content, which ...

PHP script integration with WHMCS

I've been attempting to add analytic.php into head.tpl in WHMCS, but I keep encountering an error. Analytic.php location: root/analytic.php Head.tpl location: root/whmcs/template/six/includes/head.tpl I read that WHMCS supports Smarty PHP, so I&apos ...

What advantages does Snap.svg offer compared to the HTML5 native SVG DOM API?

Can the differences between Snap.svg and HTML5 native SVG DOM API be compared to jQuery vs HTML5 native DOM? Apart from potential cross-browser disparities, assuming modern browsers support SVG well, what advantages does Snap.svg offer? What are the pros ...

What could be the reason for the modal-side modal-top-right class not functioning properly in Bootstrap modals

Here is the code snippet: <div class="modal fade right" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true"> <div class="modal-dialog modal-side modal-bottom-right"> <div class="modal-content"&g ...

Creating a sequence of isometric foes in the right arrangement or tackling the task of handling the stained rectangle?

Can someone lend a hand in fixing my Z-index order? I've been staring at this code for hours and my eyes are starting to cross. Maybe leaving a question on Stack Overflow overnight will steer me in the right direction. I've been tinkering with h ...

What is the best way to create a navigation bar that opens on the same page when clicked?

Can someone help me figure out how to create a navbar that, when clicked, opens a small window on the same page like in this example image? ...

Which javascript alternative most closely mimics the features of html5 form validation?

I just finished creating a form validation app using html5 for client side validation. Now, I am searching for a javascript implementation that can replicate this functionality in older browsers. The key qualities I am looking for include: Replicating t ...

JSON notation that spans multiple lines

Although there are many questions on this topic already, I am struggling to find the right solution for my specific case. Therefore, I have decided to move some user terms into a separate JSON file. These strings are quite lengthy. { "term&quo ...