"Ensuring Proper Alignment of Labels and Inputs in Bootstrap for Varying Column

I'm encountering alignment issues with a large form that I'm working on. I have two columns at the beginning of the form where some rows occupy half of the width while others take up the full width. However, the problem arises with the alignment of the last row, as the textareas are not aligned with the other inputs.

How can I go about fixing this?

DEMO

PS. I am using Bootstrap 4, but I believe this question is also relevant to Bootstrap 3.

.full-width {
  width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://npmcdn.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="354150415d504775041b071b01">[email protected]</a>/dist/js/tether.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
 <form novalidate>
   <div class="row">
      <div class="col-md-8">
         <div class="form-group row">
            <label for="field1" class="col-md-2 col-form-label">Text Area</label>
            <div class="col-md-10">
               <textarea id="field1" class="form-control"
                  cols="30" rows="4"></textarea>
            </div>
         </div>
      </div>
      <div class="col-md-4">
         <div class="form-group row">
            <div class="col-md-12">
               <div class="form-check">
                  <label class="form-check-label">
                  <input class="form-check-input" type="checkbox"> Checkbox 1
                  </label>
               </div>
               <div class="form-check">
                  <label class="form-check-label">
                  <input class="form-check-input" type="checkbox"> Checkbox 2
                  </label>
               </div>
               <div class="form-check">
                  <label class="form-check-label">
                  <input class="form-check-input" type="checkbox"> Checkbox 3
                  </label>
               </div>
            </div>
         </div>
      </div>
   </div>
   
   <div class="row">
   <div class="col-md-8>
      <div class="form-group row">
         <label for="field2" class="col-md-2 col-form-label">Input</label>
         <div class="col-md-10">
            <input id="field2" class="form-control"/>
         </div>
      </div>
   </div>
  </div>
   <div class="row">
<div class="col-md-12">
   <div class="form-group row">
      <label class="col-md-1 col-form-label">Options</label>
      <div class="col-md-11">
         <div class="row">
            <div class="col-md-6">
               <span>Label 1</span>
               <input type="radio" name="group1" value="Value 1"> Value 1
               <input type="radio" name="group1" value="Value 1"> Value 2
            </div>
            <div class="col-md-6">
               <span>Label 2</span>
               <input type="radio" name="group2" value="Value 1"> Value 1
               <input type="radio" name="group2" value="Value 2"> Value 2
            </div>
         </div>
         <div class="row">
            <div class="col-md-12">
               <div class="row">
                  <div class="col-md-11">
                     <textarea class="full-width"></textarea>
                  </div>
                  <div class="col-md-1">
                     <span>Icon</span>
                  </div>
               </div>
               <div class="row">
                  <div class="col-md-11">
                     <textarea class="full-width"></textarea>
                  </div>
                  <div class="col-md-1">
                     <span>Icon</span>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>
<div>
</form>

Answer №1

The issue lies with the first 2 rows being nested within col-md-8, while the misaligned "options" row is nested within col-md-12.

In addition, it is important to correct the various malformed HTML elements in the code.

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

Aligning a button with a <div> block is not achieved through styling

Take a look at the jsfiddle example. Expected result: Actual result: Here is the HTML snippet responsible for that section of the page: <input type="submit" name="BT_resetZoom" value="Reset coordinates" id="BT_resetZoom" tabindex="10" style="height: ...

Incorporating a CSS Stylesheet into an ASP.NET Custom Control

Currently, I am in the process of developing a unique custom control that consists of a combination of tables and buttons. Alongside this, there is an external CSS stylesheet that defines the styles for these specific elements. This control falls under th ...

The arrangement of columns is not correctly aligned

My website layout is giving me trouble. I want to create a three column design, but unfortunately, it's not aligning properly. Each subsequent column is being pushed down slightly more than the previous one. Is there any way to fix this issue? Interes ...

Tips for eliminating repetitiveness in situations such as BEM modifiers

As I delved into using my own adaptation of the BEM methodology, I encountered a roadblock with modifiers for nested elements. The challenge at hand is changing the link color to red when product-desc-name has the mark class. The snippet below illustrat ...

What could be causing my resize event to not trigger?

My goal is for the #sequence div to be full height of the browser window when the window size is greater than 920px in height. In such cases, I also want to trigger a plugin. If the window size is lower than 920px, then the height of the #sequence div shou ...

Position two child divs side by side within a parent div

Here's what I have accomplished so far: http://jsfiddle.net/cHKF4/3/ However, I am aiming to incorporate small boxes (box1 and box2 inside late) #late { position: relative; border-style: solid; border-width: 3px; border-color: #00ff ...

Modifying a single element within a class with Jquery

Is it possible to create a stack of pages on a website using JQuery? I found this image that shows what I'm trying to achieve: image. Instead of applying ID css for each page, I'd like to use JQuery. While researching similar questions, I came ac ...

Rotating Images in 3D with CSS

I am looking for guidance on how to create a rotating image effect on a webpage using CSS/JS. The image should rotate into the plane of the page, similar to the example shown in this post. Can you assist me with this? To better illustrate what I'm tr ...

What is the best way to adjust the spacing based on the width of the screen?

Seeking assistance with coding for a website, I have encountered an issue where I need the background to be relative to the user's screen width. However, I am struggling to find the right approach. I have attempted using relative units and media quer ...

Is the Ngx-bootstrap popover automatic positioning malfunctioning when placed on the right side of the screen?

I am currently facing an issue while implementing popovers on our application using Angular 6.0.1, Ngx-bootstrap 2.0.5, and Bootstrap 4.1.1. The problem arises when I use 'auto' positioning for the popovers, specifically on the right side of the ...

In a grid container, a child element utilizing `overflow-y: auto` will not be able to scroll

<script src="https://cdn.tailwindcss.com"></script> <div class="h-screen grid grid-rows-[auto,1fr]"> <div class="bg-slate-300 h-24 flex items-center px-4"> <h1 class="text-3xl">Navbar</h1> </div> <div ...

Utilize jQuery to convert text to lowercase before adding Capitalize CSS styling

I have encountered a situation where I need to change the HTML link values from UPPERCASE to LOWERCASE and then apply a capitalization style. The problem lies in the fact that the links arrive in uppercase, so I had to come up with a workaround: The given ...

The outcomes may vary even with identical fonts, character spacing, and line-height

When I first learned about @font-face in CSS3, I was excited about the prospect of using consistent fonts across all browsers. However, after experimenting with it using the code below on jsFiddle, my expectations were challenged: HTML: <div> T ...

"Implementing CSS inline styles for improved appearance on a Safari browser when visiting

Having some trouble using CSS to create rounded corners on my Facebook fan page. Everything works fine except for Safari browser. I've tried inline styles and a separate stylesheet, but no luck. Any help would be appreciated. My CSS for rounded corne ...

Develop rounded edges for a div element

I am interested in developing an HTML-based chart similar to the one shown below, but I am unsure of the steps to take. https://i.sstatic.net/2jLPO.png ...

Create a circular rolling image effect using CSS3 and jQuery when the page is loaded

My div box features a rounded image that I want to roll like a ball on the floor after the page loads. After rolling, I want to position the image perfectly at the center of the box. css: #box{width:900px;height:150px;position:relative;background:red;ove ...

What is the solution for aligning <grid> containers to match the height of the tallest container in the row?

I've been grappling with a CSS issue. I'm attempting to ensure that my accordion containers within my layout all have the same height as the tallest item on their respective rows. This would create a sleek and responsive layout where all items ar ...

Is there a way to automatically add a div to the window as the user scrolls and then hide the div when they scroll back to the

Seeking assistance with creating a function that will add a 'sticky' class to the menu when the user scrolls down to the middle, and then append a div when the 'sticky' class is present. Currently facing issues where the div keeps appen ...

Show Text When Clicking Within Separate DIVs

I have a set of three divs. One contains a Twitter icon, another holds a LinkedIn icon, and the last one is designated for displaying text upon clicking. My goal is to click on the Twitter icon and have corresponding text appear in the third div. Then, if ...

Tips for altering the appearance of the material-ui slider thumb design when it is in a disabled state

Through the use of withStyles, I have successfully customized the style of the Slider: const CustomSlider = withStyles(theme => ({ disabled: { color: theme.palette.primary.main }, thumb: { height: 24, width: 24, }, }))(Slider); How ...