Guide to aligning 2 divs side by side using bootstrap

I have been experimenting with different methods like col-xs-6 for the first child, but I can't seem to get it right. How can I achieve this layout using only Bootstrap?

Despite trying col-xs-6, I still haven't been able to place these divs next to each other as desired. Any tips on how to make it work within Bootstrap?

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fc9e9393888f888e9d8cbcc9d2ced2cf">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <div class="container-md bg-danger center-block ">
      <form>
        <div class="col">
          <div class="text-center">
            <label for="job-name">Type job name</label><br>
            <input type="text" class="form-control-lg border-success text-center rounded-circle " id="job-name " rows="3" placeholder="Job-name">
          </div>
          
          <div>
            <label for="first-name">Type first name</label><br>
            <input type="text" class="border-dark form-control-lg-mb2 mt-2 ml-2 text-center rounded-right" id="first-name" rows="3" placeholder="first Name" required><br>
          </div>
          
          <div class="align-self-right">
            <label for="last-name">Type last name</label><br>
            <input type="text" class="border-dark form-control-lg-mb2 ml-2 text-center rounded-right" id="last-name" rows="3" placeholder="Enter your last Name" required><br>
          </div>
          
          <div class="align-self-right">
            <label for="last-name">Type Phone number</label><br>
            <input type="text" class="border-dark form-control-lg-mb2 ml-2 rounded-right" id="last-name" rows="3" placeholder="Enter your Number"><br>
          </div>
          
          <div class="align-self-right">
            <label for="last-name">Type Email</label><br>
            <input type="text" class="border-dark form-control-lg-mb2 ml-2 rounded-right" id="last-name" rows="3" placeholder="Enter your Email"><br>
          </div>
          
          <div class="align-self-right">
            <label for="last-name"> Age</label><br>
            <input type="date" class="border-dark form-control-lg-mb2 ml-2 rounded-right" id="last-name" rows="3" placeholder="Enter your last Name"><br>
          </div>
        </div>
        
        <div class="col">
          <div class="text-right">
            <label for="last-name"> Age</label><br>
            <input type="date" class="border-dark form-control-lg-mb2 ml-2 rounded-right" id="last-name" rows="3" placeholder="Enter your last Name"><br>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

Answer №1

To ensure proper alignment, simply place the columns within a row and the formatting will function as anticipated.

For instance:

<div class="row">
<div class="col-6">column 1</div>
<div class="col-6">column 2</div>
</div>

If your issue involves form disruption, relocate the row inside the form element for seamless integration.

<form>
<div class="row">
<div class="col-6">column 1</div>
<div class="col-6">column 2</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

Hover effect triggered upon mouse exit

As I delve into learning the basics of HTML and CSS, I came across the :hover property in CSS. This unique feature allows for a specific action to occur when the cursor hovers over an element, based on the code provided. Additionally, I discovered the tran ...

Step-by-step guide on utilizing jQuery to fade out all elements except the one that is selected

There are multiple li elements created in this way: echo '<ul>'; foreach ($test as $value){ echo '<li class="li_class">.$value['name'].</li>'; } echo '</ul>'; This code will generate the fol ...

Display the contents of a <div> tag from one HTML file onto another HTML file

Recently I embarked on learning HTML and came across a peculiar doubt. My goal is to create a section div on the first page that changes dynamically based on the menu item clicked, rather than redirecting to another HTML page. I've experimented with s ...

Tips for centering a horizontal unordered list within a division element

I can't seem to figure out why the text-align center isn't working. I've followed other tutorials and applied the textalign: center to the div, then added display: inline to the ul. Below is a sample of my HTML code from the browser as I am ...

Click the button to trigger the pop-up

After creating a photo gallery using a plugin, my goal is to display this gallery when the user clicks on my homepage button. I am unsure how to make this happen and would appreciate any assistance. Below is my button code: <div class="ow-button-base ...

As the user scrolls down, the navigation becomes obscured by the content

Whenever I scroll down on my website at Bradly Spicer, the navigation menu extends and ends up falling behind the content. This is the script I am using: .menu { position: relative; z-index:9999; } .post { background: #fff; border: 1px solid #ddd; font- ...

Troubleshooting Problems with CSS Media Queries on Various 1280 screens

I'm facing an issue with creating a responsive layout using CSS media queries to adapt to different screen resolutions. Even though I've set up Media Queries for specific resolutions like: /*1280 x 1024*/ /*1280 x 960*/ /*1280 x 800*/ /*1280 x 7 ...

Modifying Div Size with Jquery

I am working on populating the div container with square boxes, but I'm having trouble adjusting the size of my #gridSquare div. Despite trying to change its height and width using jQuery, it doesn't seem to work as expected. $('#gridSquare ...

Tips for automatically inserting a "read more" link once text exceeds a certain character count

Currently utilizing an open-source code to fetch Google reviews, but facing an issue with long reviews. They are messing up the layout of my site. I need to limit the characters displayed for each review and provide an option for users to read the full rev ...

Elements floating in space, stretching across the entire width

In my design, I have a fixed size layout with a centered content container. My goal is to have the menu (home, about, contact, login) span 100% of the screen width. You can view the current setup in this jsfiddle: http://jsfiddle.net/Hxhc5/1/ I am aimin ...

Creating a weather format user interface in HTML can be accomplished by following a few

I am currently utilizing the open weather API to showcase weather data, however, I am facing difficulties in arranging the data in a format similar to the one shown below. Example output: I attempted to present the data in the following structure: ...

How to customize Material UI Autocomplete options background color

Is there a way to change the background color of the dropdown options in my Material UI Autocomplete component? I've checked out some resources, but they only explain how to use the renderOption prop to modify the option text itself, resulting in a a ...

Applying CSS to select a different element style within a webpage

I was thinking about the possibility of linking one style to another using events like :focus or :hover in CSS alone, without the need for JavaScript. For instance, can the class "hitArea" change the background attribute of "changeArea" when it is in foc ...

What is the best way to hide only the rows in a table when it is clicked using JavaScript?

Is there a way to hide rows in these tables by clicking on the table head? I'm currently using bootstrap 5 so JQuery is not an option. <table class="table table-info table-bordered"> <thead id="tablea"> ...

Guide to crafting a flawless pixel-perfect separator with CSS borders

I have a menu with a black background and a submenu with a grey background. Now, I want to add a pixel-perfect divider between them. However, I'm unsure of which border color to use in order to achieve this perfection. Can anyone provide some guidan ...

Passing information from Vue to a modal

I'm working with 3 components: TaskList, TaskItem, and TaskForm. Within the TaskList component, there is a loop that renders all the data in TaskItem. Each TaskItem has an edit button meant to open a TaskForm modal (using bootstrap) displaying the sp ...

Field input displacement

I am experiencing an issue with my contact form, specifically with the message subject field displayed as a menu. The problem only seems to occur on wide desktop displays, where it appears offset from the rest of the form. Despite my efforts to troublesho ...

Incorporating text overlays on images that are compatible with responsive websites is a top priority for me

This is a piece of HTML code that utilizes bootstrap 3 for design purposes. The challenge faced is related to positioning text over an image. When resizing the browser, the alignment of the text with the background gets disturbed. Assistance is needed in r ...

Generating a dynamic triangle within a div while ensuring it fits perfectly with the maximum width

I need help with creating a responsive triangle on a web page that takes three inputs. The challenge is to adjust the size of the triangle so it fits inside a div element while maintaining the aspect ratio of the inputs. For instance, if the inputs are 500 ...

The Disabled element does not exhibit effective styling

When we include the disabled attribute in the text element, the style does not work. Can you explain why? <input pInputText [style]="{'padding-bottom':'10px','padding-top':'10px','width':'100%&apos ...