Aligning bootstrap side by side fields poses a challenge when labels are missing

I am struggling to design a basic bootstrap layout as I am facing challenges in aligning controls that lack labels.

The problem can be seen in the provided fiddle. The controls (textbox and button) in the third column are not aligned next to the Last name textbox. I have experimented with classes like mt-2 and align-bottom but haven't had any success. Can anyone offer assistance?

Link to fiddle

Below is the HTML snippet:

<div class="row">
                     <div class="col-xs-4 col-lg-4">
            <label for="firstNameInput" class="control-label">First Name</label>

           
                <input type="text" id="firstNameInput" class="form-control" />
            </div>


 <div class="col-xs-6 col-lg-5">
            <label for="lastNameInput" class="control-label">Last Name</label>            
          
                <input type="text" id="lastNameInput" class="form-control" />
            </div>
<div class="col-xs-2 col-lg-1 mt-5 align-baseline">   
        <input type="text" class="form-control" />
    </div>
    
</div>
<div class="row">
                     <div class="col-xs-4 col-lg-4">
            <label for="firstNameInput" class="control-label">First Name</label>

           
                <input type="text" id="firstNameInput" class="form-control" />
            </div>


 <div class="col-xs-6 col-lg-5">
            <label for="lastNameInput" class="control-label">Last Name</label>            
          
                <input type="text" id="lastNameInput" class="form-control" />
            </div>
<div class="col-xs-2 col-lg-1 mb-0 align-baseline">   
        <input type="submit" value="Submit" class="btn btn-primary" />
    </div>
    
</div>

The red line indicates the alignment discrepancy. The controls in the third column should align with the Last name text boxes.

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

Appreciate your help

Answer №1

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7d70706b6c6b6d7e6f5f2a312d312c">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
  <div class="col-xs-4 col-lg-4">
    <label for="firstNameInput" class="control-label">First Name</label>


    <input type="text" id="firstNameInput" class="form-control" />
  </div>
  
  <div class="col-xs-6 col-lg-5">
    <label for="lastNameInput" class="control-label">Last Name</label>

    <input type="text" id="lastNameInput" class="form-control" />
  </div>
  <div class="col-xs-2 col-lg-1 d-flex align-items-end">
    <input type="text" class="form-control" />
  </div>

</div>
<div class="row">
  <div class="col-xs-4 col-lg-4">
    <label for="firstNameInput" class="control-label">First Name</label>


    <input type="text" id="firstNameInput" class="form-control" />
  </div>


  <div class="col-xs-6 col-lg-5">
    <label for="lastNameInput" class="control-label">Last Name</label>

    <input type="text" id="lastNameInput" class="form-control" />
  </div>
  <div class="col-xs-2 col-lg-1 mb-0 d-flex align-items-end">
    <input type="submit" value="Submit" class="btn btn-primary" />
  </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

Interacting with local data using Express server

I am currently in the process of developing a web application for my web art class using Node.js with npm and Express. The concept behind the site is to have the entire body colored in one solid color, but allow users to text a hexcode/CSS color to a Twili ...

The variable continuously updates itself inexplicably, without any specific code dictating it to

In the sandbox-based game I am playing, two variables are present. blocks (this is an array) and blockssave (also an array) However, there are also functions included: var game = { blocksave: function() { blockssave = blocks; blo ...

The AngularJS plugin "chosen" is experiencing issues with the "chosen:updated" feature, despite functioning

After successfully integrating the selected plugin into my AngularJS app, my app.js file now has the following code: myApp.directive('chosen', function() { var linker = function (scope, element, attr) { scope.$watch('countriesL ...

Warning: CSS Validation Notice - Identical color and background-color used in two different contexts

I have been receiving numerous warnings similar to the ones mentioned below during a CSS validation check via > 513 Similar color usage for both text and background in multiple areas such as #blue_module and #red_module_top, .content ul li and # ...

Using single-line ellipsis with the Material-UI select and option components

I have a TableHead Component with multiple columns. Among them is a <Select> element that allows users to filter the table content based on one of four statuses. I am trying to implement an ellipsis at the end of the option string if it exceeds its c ...

Having trouble interacting with element - Selenium WebDriver is not allowing the click

I'm attempting to select the Checkout Button. This is what it looks like : https://i.stack.imgur.com/TiMEO.png And here's the HTML snippet for it : <div id="buy-button-next"> <span data-reactroot=""> <div data-cid="buy- ...

Setting background colors for classes based on an array

I have a total of six div elements on a single page, all sharing the same class. My goal is to give each one a unique color from an array I have prepared. I want to avoid any repetition of colors among these divs. Currently, I have managed to assign backg ...

Utilizing button clicks to send fetch commands and extract data from websites

I need help with my Google Chrome extension. I have some fetch commands for an API, but I'm not sure how to send them when a button is clicked. Can someone guide me on the right approach? Is there a recommended method for a Chrome extension to extrac ...

Steps for positioning a div beside a centered div

Is there a way to position a div next to another div that is centered on the page, like this: .firstDiv { margin-left: auto; margin-right: auto; padding: 0; } The above code centers the first div in the middle of the page. But how can I add a ...

Guide on displaying Adsense ads specifically for mobile devices

Can anyone provide me with a proper method to show/hide my AdSense ads on both mobile and desktop? I am currently using a method that results in 2 console errors. Here is the current approach: We are utilizing two classes, "mobileShow" and "mobileno," t ...

The second tab on Bootstrap5's tab content feature seems to generate an endless amount of white

I am working on a project where I need to display statistics for both the current month and year. To organize this data, I created a card with tabs for each - one tab for the month and another for the year. By default, the month tab is loaded first. Howev ...

Exploring the possibilities in Bootstrap 5.3: Modifying the maximum width of an individual tooltip

Is there a way to modify the maximum width of a specific Bootstrap Tooltip without affecting the others? I do not utilize Sass or SCSS, and have attempted various methods outlined in the documentation: tooltip-max-width="300px" bs-tooltip-max-wid ...

The utilization of CSS variables within intricate properties

Imagine having a CSS property called box-shadow: box-shadow: 5px 5px 0 #ccc; What if there is a need to create a variable from the color #ccc? While in SCSS, you could accomplish this with code like: $grey: #ccc; .element { box-shadow: 5px 5px 0 $gre ...

Whenever I change the value of a textbox using plain JavaScript, the text becomes hidden from view

I'm struggling to understand why this function is making the textbox value invisible. I attempted changing the hidden field to a visible field, but that didn't solve the issue. Would appreciate some guidance. Here's the complete page code, p ...

How can I trigger an Onclick event from an <a tag without text in a Javascript form using Selenium?

Here is my original source code: <a onclick="pd(event);" tabindex="0" issprite="true" data-ctl="Icon" style="overflow: hidden; background: transparent url("webwb/pygridicons_12892877635.png!!.png") no-repeat scroll 0px top; width: 16px; height: 16px ...

I am looking for guidance on removing the bottom line from the ionic 4 segment indicator. Any advice or tips on

.segment-button-indicator { -ms-flex-item-align: end; align-self: flex-end; width: 100%; height: 2px; background-color: var(--indicator-color); opacity: 1; } I am a beginner in hybrid app development and ...

Constructing an HTML table with PHP echoes

I am currently developing a PHP script for tracking user attendance. The structure I am aiming for is as follows: Alternatively, you can view my jsFiddle <form action='this_page.php' method='post'> <table> <th>Me ...

Tips on enlarging a webpage without showing the scroll bar on the main component

My goal is to create a webpage that resembles a window application. However, I've encountered an issue where zooming in on the page results in a scroll bar appearing on the main page. The parameters for the main page (the parent) are set as follows: w ...

Three divs are positioned within the parent element and collectively fill the entire height. The first and last div have varying

I attempted to replicate the design shown in the image below: https://i.sstatic.net/Q7sTI.png Initially, I was successful in achieving this using JavaScript. However, when attempting to recreate the same effect using only CSS without any JavaScript, I en ...

What is the best way to apply overlays to customize a specific part of a single character while also accommodating dynamic width adjustments?

Query Is it feasible to style a specific portion of a single character? Interpretation You cannot apply CSS attributes to parts of characters. However, if you wish to style only a particular section of a character, there is currently no standardized met ...