"Revamping Form Layouts with Bootstrap's Horizontal Alignment and Column

I am diving into a new adventure by working with a Bootstrap Horizontal Form for the first time. I have followed their example and now trying to convert it into 4 columns. In my design, Columns 1 and 3 will house field labels while Columns 2 and 4 will contain the field inputs.

My goal is to keep the rows in Columns 1 and 2 completely independent of the rows in Columns 3 and 4. This means, if there is a radio button set in Row 4, it should not affect the height of a text input in Row 2. Here's how I have set it up:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form>
  <div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-4">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
    
    <fieldset class="form-group">
    <div class="row">
      <legend class="col-form-label col-sm-2 pt-0">Radios</legend>
      <div class="col-sm-4">
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
          <label class="form-check-label" for="gridRadios1">
            First radio
          </label>
        </div>
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
          <label class="form-check-label" for="gridRadios2">
            Second radio
          </label>
        </div>
        <div class="form-check disabled">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
          <label class="form-check-label" for="gridRadios3">
            Third disabled radio
          </label>
        </div>
      </div>
    </div>
  </fieldset>
    
    
  </div>
  <div class="form-group row">
    <label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
    <div class="col-sm-4">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  
  
  
  <div class="form-group row">
    <div class="col-sm-2">Checkbox</div>
    <div class="col-sm-4">
      <div class="form-check">
        <input class="form-check-input" type="checkbox" id="gridCheck1">
        <label class="form-check-label" for="gridCheck1">
          Example checkbox
        </label>
      </div>
    </div>
  </div>
  <div class="form-group row">
    <div class="col-sm-10">
      <button type="submit" class="btn btn-primary">Sign in</button>
    </div>
  </div>
</form>

The current look is far from ideal - struggling to figure out how to create effectively 2 columns on horizontal tables with fields that operate independently. The issue right now is that the radio buttons are affecting the size of the gap between email and password fields in the first column of field inputs. My aim is to make these two sections entirely separate from each other if possible.

Answer №1

Add the Class col to the following fieldset:

<fieldset class="form-group col">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form>
  <div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-4">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
    
    <fieldset class="form-group col">
    <div class="row">
      <legend class="col-form-label col-sm-2 pt-0">Radios</legend>
      <div class="col-sm-8"> <!-- change Here -->
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
          <label class="form-check-label" for="gridRadios1">
            First radio
          </label>
        </div>
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
          <label class="form-check-label" for="gridRadios2">
            Second radio
          </label>
        </div>
        <div class="form-check disabled">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
          <label class="form-check-label" for="gridRadios3">
            Third disabled radio
          </label>
        </div>
      </div>
    </div>
  </fieldset>
    
    
  </div>
  <div class="form-group row">
    <label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
    <div class="col-sm-4">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  
  
  
  <div class="form-group row">
    <div class="col-sm-2">Checkbox</div>
    <div class="col-sm-4">
      <div class="form-check">
        <input class="form-check-input" type="checkbox" id="gridCheck1">
        <label class="form-check-label" for="gridCheck1">
          Example checkbox
        </label>
      </div>
    </div>
  </div>
  <div class="form-group row">
    <div class="col-sm-10">
      <button type="submit" class="btn btn-primary">Sign in</button>
    </div>
  </div>
</form>

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

Refresh the texture mapping within ThreeJS

Hey there! Just wanted to share that I was able to find a solution by using mesh.material.map.image.src = texture; Here was the original question: I'm working on a ThreeJS project and I'm trying to change the texture on a mesh. Unfortunately, I ...

Substitute the aircraft in the cosmos with ThreeJS

I am trying to adjust the position of a plane in ThreeJS to a specific Z value. Using shapeBufferGeometry with vectors containing x, y, and z values. Below is my code and the current output. I want the white plane to align with the aqua lines. The code ...

Learn how to create a validation function for phone numbers in a React application that keeps the button disabled until a valid phone number

import React,{useState} from "react"; export default function ValidatePhone() { const [phoneNumber, setPhoneNumber] = useState(""); const [disableButton, setDisableButton] = useState(true); function handleChange(e) { setPho ...

Sending data to JavaScript in ExpressJS

I am facing a bit of confusion here; I am utilizing NodeJS to retrieve a JSON file and I want to pass the data to my web page so that JavaScript can utilize it. app.get('/test', function(req, res) { res.render('testPage', { ...

Stop the closure of confirmation box by disabling the space key

I've been working on a website that features a table for users to interact with. Within one column of the table, there are input boxes where users can write notes. Below each input box, there is a save button to store the entered notes in a database. ...

The custom tooltip is not being displayed as intended

I'm currently working on customizing tooltips in angularjs google charts. My goal is to display multiple series data along with some text within the tooltip, similar to the demo showcased here. Specifically, I aim to include the legend and title of th ...

Retrieve a JSON file from a different tab or window

My setup includes two servers: one dedicated to hosting HTML content and the other functioning as an API for connecting to Twitter. To initiate the process, I open a new tab (or window) on the HTML Server to invoke the API, which then redirects to the T ...

Searchbox aligned to the right using Bootstrap

Looking to place a searchbox on the right next to another container aligned left: <div> <div class="pull-left"><span>SOME TEXT</span></div> <div class="pull-right"> <div class="row"> ...

attempting to fulfil a promise through a resolution

I am currently attempting to use a resolve with a promise in response to an issue with filters that I am currently tackling. However, my resolve function is not yet functioning as expected. I have decided to implement this approach based on advice I recei ...

Bidirectional updates in AngularJS with CSS styling

On the backend, certain HTML elements store their position and size persistently and retrieve them when the page loads. These elements can be dragged and resized by users, with any updates needing to be saved on the backend for consistency across sessions. ...

Issue: The key length and initialization vector length are incorrect when using the AES-256-CBC encryption algorithm

Within my coding project, I have developed two essential functions that utilize the AES-256-CBC encryption and decryption algorithm: import * as crypto from "crypto"; export const encrypt = (text: string, key: string, iv: string) => { con ...

What is the best way to align a div block with images horizontally?

Trying to center a block of images horizontally, but struggling to get the alignment right. The HTML code looks like this: <div id="dealerarea"> <div id="dealercards"> <!--Images by Javascript--> </div> </div> He ...

Incorporate Margins for Table Cells in Outlook (HTML Email)

I'm currently in the process of creating an email newsletter and testing it out on Litmus. Here's how the newsletter design should appear (refer to the image below): Although I understand that it may not look exactly the same on Outlook, is the ...

Prevent duplicating ReactJs when using Gulp: A guide

My current project involves using ReactJS as the view library for client-side rendering. Additionally, I am utilizing a lot of components from Material-UI in my application. One challenge that I have encountered is the need to use gulp for setting up brows ...

Guide to Deactivating the ENTER Key Functionality in React Material UI Autocomplete Form

My React component features a Material UI Autocomplete form that is working perfectly, except for one issue - when the user hits ENTER, the input field gets cleared. I simply want to prevent the input field from being cleared when ENTER key is pressed. Des ...

Having trouble integrating document.getElementById('password').addEventListener() in a webpack and ES6 environment

I have a project where I am utilizing webpack and ES6 classes. In this particular scenario, I am attempting to trigger the 'onblur' function on input#password but unfortunately, it is not working as expected. Strangely, there are no errors thrown ...

The html-docx-js package generates incomprehensible text

Has anyone successfully utilized html-docx-js recently? I attempted the following code snippet: var newHTML = "<!DOCTYPE html><html><head lang='en'><meta charset='UTF-8'><title>Report</title& ...

The hyperlink does not appear to be functioning properly within a specific Div on the iPad. Interestingly, this issue does not persist when using other

Apologies if I am posting this question in the wrong place. I have a webpage (built with asp.net/vb) where each section is contained in divs within a Bootstrap grid. Through the code behind, I am attaching onclick events to each set of divs to perform sp ...

Laravel and Vue: tackling pagination issues in a Vue.js and Laravel application

I'm struggling with getting Laravel pagination to function properly. Although I attempt to access results from different pages, I find that I can only retrieve the first page. Even when I click on page 2, upon checking the request payload, it always i ...

How to eliminate the divider before the first menu item in WordPress

When it comes to adding "/" as separators before all menu items except the first, I'm encountering a challenge. I've successfully inserted the separators, but I'm struggling to remove only the first one. Here's the CSS code I've be ...