The Bootstrap 4 grid system does not automatically use floats

While using bootstrap 4 to develop a website, I encountered an issue where my columns were not floating automatically as expected. I'm not sure if this is a Bootstrap 4 problem or if I am missing something. I know custom CSS can solve the issue, but I feel like there's something I'm overlooking. Can someone please help?

<?php
include ("layouts/header.php");
?>
<section class="booking">
    <div class="container">
        <div class="row">
            <div class="section-header">
                    <h2>Booking Procedures</h2>
                </div>
            <div class="section-content">
                <div class="col-12">
                    <form>
                        <div class="card text-center">
                          <div class="card-header">
                            Booking Step 2 Of 2
                          </div>
                          <div class="card-block">
                            <p>All * fields are compulsory</p>
                            <div class="col-12 col-md-3">
                                <div class="form-group">
                                    <select class="form-control">
                                        <option>Title</option>
                                        <option>Mr.</option>
                                        <option>Mrs.</option>
                                        <option>Miss</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-12 col-md-3">
                                <div class="form-group">
                                    <input type="text" class="form-control" placeholder="First Name *" />
                                </div>
                            </div>
                            ... // Rest of the form elements
                            <div class="col-12">
                                <div class="form-group">
                                    <button type="submit" class="btn btn-sample3">Submit</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
<?php include("layouts/footer.php"); ?>

Desired Result: https://i.sstatic.net/j31p1.png

Actual Result: https://i.sstatic.net/UVPsh.png

Answer №1

Your code needs to be properly formatted. Make sure you are using col- inside a row in Bootstrap. Here is an example:

<div class="container">
  <div class="row">
    <div class="col-12">
    </div>
  </div>
</div>

If you need to nest rows, follow this structure:

<div class="container">
  <div class="row">
    <div class="col-12">
      <div class="row">
        <div class="col-12">
        </div>
      </div>
    </div>
  </div>
</div>

For more information, check out the documentation: https://getbootstrap.com/docs/4.0/layout/grid/#nesting

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

I'm perplexed as to why my attempts to override a specific Bootstrap style with my own style sheet are proving unsuccessful

Currently, I am in the process of developing a basic website with the assistance of bootstrap and encountered an issue while trying to customize the appearance of an alert box. In my code structure, I have linked the Bootstrap CSS followed by the Bootstra ...

Aligning Your Header and Wrapper in Bootstrap 4

I am attempting to align my header with my 1024px wrapper. Below is the code snippet: https://codepen.io/anon/pen/wLRgyN. My goal is to align the 300x100 section to the right and the navigation to the left of each side of the wrapper in order to achieve a ...

Dividing one SVG into Multiple SVGs

I'm facing a challenge with loading an SVG overlay on a Google Map. The SVG file is quite large, about 50mb, resulting in a delay of around 10 seconds for it to load in the browser. One solution I'm considering is splitting the SVG into 171 smal ...

Refresh WebPage automatically after a Servlet successfully uploads and processes an image

I have a webpage that includes an image and a button. When the button is clicked, it uploads the image by submitting a form to a file upload servlet. However, after successfully uploading the image, the servlet does not display it in the img tag. Here is ...

The keyframe spinner fails to function properly on Firefox and results in blurry text

I am facing an issue with a keyframe spinner that rotates an image on the y-axis. It works perfectly in Chrome but fails to function in Firefox. I have tried changing the HTML tags to div or span class/id, but nothing seems to work. Interestingly, other ke ...

Struggling with CSS float problems

I'm currently working with the Pure CSS framework and my code resembles this: <div class="container pure-g"> <header class='pure-u-1'> <h1 class='logo'> <a href="#">TEST</a> </h1> &l ...

What is the best way to generate an extensive table with HTML and AngularJS?

I am looking to implement an expandable table feature where a single header with a plus icon can be clicked to reveal the child rows beneath it. Currently, I have been able to achieve this functionality. However, I am facing an issue where the child rows ...

The labels assigned to buttons will direct users to unique links specifically designated for that button

I've been working on a website to share some code I created, but my skills in HTML and CSS are not the best. Please forgive me if there are obvious mistakes. Here's the code I have so far: <!DOCTYPE html> <html> <head> ...

What could be the reason the background-color isn't changing when I apply button:hover?

body{ font-family:"Arial","Lucida Grande", "Lucida Sans Unicode", Verdana, Helvetica, sans-serif; font-size:12px; } p, h1, form, button{border:0; margin:0; padding:0;} .spacer{clear:both; height:1px;} /* ----------- My Form ----------- */ .myform{ margin:0 ...

Is there a way for me to set up a confirmation pop-up alert before hitting the submit

I am interested in implementing a pop-up alert that asks "Are you sure you want to delete this comment?" when a user clicks on a button. How can I achieve this? $('button').on('click', function(){ // Display an alert to the user c ...

Ways to show buttons as inline or block elements when a single button is enclosed within a form

Need help figuring out how to make two buttons display as block elements on small screens and inline elements on larger screens, especially when one button is wrapped inside a form? I am struggling with displaying two buttons on my page. One of the button ...

Navigate back to the previous slide utilizing slick and jquery

I am facing an issue with my slides that have multiple calls to actions opening different slide on click For example, if a user is on slide number 1 and clicks a button to open slide number 5, then upon clicking the go back button it should return to slid ...

Manipulating a specific element within an ng-repeat in AngularJS without affecting the others

I'm currently working on developing a basic single page application to monitor people's movements. While I've made good progress, I've encountered an issue with the click function in the child elements of each person div. When I try to ...

What is the best way to refresh information following its removal?

In my app, I have implemented a feature where posts are displayed as HTML cards using a component called PostList. Each card has a delete button to remove it from the list. The issue I am facing is that when I delete a card, it remains visible in the post ...

Guide to altering the red color of required fields in Joomla

Is there a way to change the color of the required input field in Joomla when it is empty? I'm looking for the code that controls this functionality. ...

Creating a unique directive in Angular 2 with custom bindings

I have implemented a custom directive in my HTML file which displays different errorType messages for my component, msgfooter: <msgfooter [errorType]="Invalid server"> <msgfooter> or <msgfooter [errorType]="Few Parameters"> <msgfoot ...

What steps can be taken to ensure that this form fields are flawless?

Can you style the form fields to match the red line in this image? https://i.sstatic.net/gbvDs.png input, select, textarea { width: 20%; padding: 12px; border: 1px solid #ccc; box-sizing: border-box; margin-left: 20px; } label { padding: 12 ...

PHP Table Sorting Functionality

After inputting the correct code, I am still facing an issue with the table sorting not showing up. Can someone assist me with this problem? I have included both my CSS styles and PHP coding. Thank you for your help! Here is a visual representation of the ...

Styling the Bootstrap Side Navigation Bar for Desktop View

My bootstrap navbar has a unique feature where the menu slides out from the right when clicked on mobile and small viewports. However, I want it to display the standard bootstrap styles for the desktop version (no menu button, just inline menu items in t ...

Consistent Row Heights for Dynamic Width Elements

I've relied on Chris Coyier's Equal Height Blocks in Rows jQuery script for various projects, and it has consistently delivered great results. However, this time I am facing a new challenge as I work on a responsive website with a fluid width ma ...