Bootstrap 4 row mysteriously shatters apart

I have searched for solutions to this issue but none of them on this forum have been helpful. Hopefully, someone here can offer some assistance. I am facing a problem with displaying 4 columns of data in one row:

Here is the code snippet causing the layout issue:

<hr class="mb-4">
    <div>
        <h3>{{ player.full_name }}</h3>
        <h4> {{ player.position }}</h4>
        <h5> {{ player.team }}</h5>
    </div>
    <hr class="mb-4">
    <div class="row">
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Form
            </div>
            <div class="text-center ">
                {{ player.form }}
            </div>
        </div>
       <!-- more content -->

The problem arises when viewing this on smaller screens where the columns do not remain in one row as intended. Here's what it looks like:

No matter what changes I make, I cannot seem to resolve this issue. I want all columns to be displayed in the same row even on smaller screens. Any help would be greatly appreciated.

Edit The root cause of the problem seems to be in the header section of my page.

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <!-- more head content -->
</head>

It appears that the issue arises from using Bootstrap 4 instead of Bootstrap 3 as seen in the example below. Is this behavior intentional?

Answer №1

To ensure it appears in 4 columns on all screen sizes, simply apply the col-3 class instead of col-xs-3 col-sm-3

Answer №2

It appears that I am unable to replicate this issue on my end. It is possible that there may be a discrepancy in your CSS code:

<!DOCTYPE html>
<html lang="en>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
    <!-- Bootstrap core CSS -->
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>
<hr class="mb-4">
    <div>
        <h3>Mohamed Salah</h3>
        <h4>Midfielder</h4>
        <h5>Liverpool</h5>
    </div>
    <hr class="mb-4">
    <div class="row">
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Form
            </div>
            <div class="text-center ">
                7.5
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Price
            </div>
            <div class="text-center">
                <span>&#163;</span>12.8
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Total
            </div>
            <div class="text-center">
                165
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                TSB
            </div>
            <div class="text-center">
                45.3%
            </div>
        </div>
    </div>

    </div>
    <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
  </body>
</html>

You can try it yourself by visiting the following link: https://codepen.io/davidgbiggs/pen/JjdXpGq

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

How to fill HTML <select> options using the GET Method

I am looking to populate a dropdown list with values from a repository in Qlik Sense using HTML. Are there any suggestions on how to achieve this without using PHP? As a beginner in this field, I would appreciate any guidance or assistance. UPDATE: Here ...

When the button is clicked, redirect to a new page and submit a form using AJAX with data obtained from the click event

I have a page called 2.html where inputting an ID number results in some output being displayed. This functionality is achieved using Ajax post method, sending data along with the data parameter. I also have another page named 1.html that contains a list o ...

Placing elements in Chrome compared to IE

I'm currently attempting to position elements in two rows using mathematical calculations. One of the elements, thumb_container, is a div that is absolutely positioned. Within this container, I am dynamically loading and appending image thumbnails usi ...

Some devices experiencing website update issues while others are successful

My website is functioning properly on my laptop and phone, but not on my school iPad (managed by the district). I have already cleared the cache, but the site does not update. It was working fine earlier, and I need to present it next Monday. Please help a ...

What causes these images to stack on top of one another rather than align in rows? [HTML][CSS][Bootstrap]

I've implemented Bootstrap's grid system to showcase two rows, each containing two images. Here is the code: <section class="container"> <div class="row"> <figure class="column-sm-6"> <p>floor pl ...

AngularJS allows you to toggle the visibility of a div at set intervals, creating

I am struggling with the task of showing and hiding a div that serves as an alert for my application. Currently, I am using $interval to create a continuous show and hide action on the div. However, what I aim for is to have the DIV visible for X amount o ...

Spin an object on a stationary axis

https://i.sstatic.net/8dT9W.gif Is there a method to create a similar effect using CSS, JS, or GSAP? ...

Is there a simpler method to access the source element for an event?

I'm just starting to learn JavaScript and jQuery, and right now I have the following code in my HTML: <a id="tog_table0" href="javascript:toggle_table('#tog_table0', '#hideable_table0');">show</a> After that, I hav ...

When the button is clicked, populate a new form with information from the model

As a newcomer to stackoverflow and django, please excuse me if my description is lacking in detail. This is the models.py file: from django.db import models # Create your models here. SPORTS_CHOICES = ( ('nfl', 'NFL'), (&apos ...

In my attempt to position Font Awesome icons alongside a button icon and create equal spacing between them, I want to achieve the layout displayed in the example

How can I align Social Icons using Font Awesome like in the example provided below? I've tried targeting the Icons but I can't seem to adjust the padding or margin. What am I overlooking? - EXAMPLE <!--BOOTSTRAP--> <link rel="styles ...

Footer remains fixed and scrolls into the body when the window is resized

Having trouble with the footer's responsiveness when resizing the desktop window. It looks fine in developer tools, but in different browsers, the footer placement gets messed up and scrolls over the rest of the content. Any insights on what might be ...

Building a stack of DIVs, some with fixed heights and others without, potentially using only CSS

Hello everyone! I am having trouble deciding on the best approach to achieve a layout like the one below: +------------------------------------------------------------+ | div 0 , varying height +---------------------------------------------------------- ...

Updating the global CSS styles that were inherited from the node_modules folder in a Next.js project

I've been attempting to customize the CSS style for a rc-pagination component that was included in a CSS file I already imported in the root component _App. However, despite my efforts to override the styles in the index.css file of this component, no ...

What is the best way to add an inset shadow with a transparent background in SVG?

I created a basic SVG Icon, but I'm having trouble adding an inset shadow effect to it. Is there a way to achieve this? svg { filter: drop-shadow(0.1px 1.5px 0.1px rgba(0,0,0,0.5)); } <!DOCTYPE html> <html> <body> <svg width ...

As soon as I hit the submit button on my website form, the URL is automatically refreshed with the information I provided

I am a beginner when it comes to forms and recently copied and pasted this login snippet code: <div class="login-form-1"> <form id="login-form" class="text-left"> <div class="main-login-form"> <div class="login-group"> ...

Imitate a style using jQuery without deleting other elements

This is an example of HTML code: <div id="id1" style="width:100px;background: rgb(196, 14, 14);">1</div> <div id="id2" style="margin-top:10px">2</div> to <div id="id1" style=&qu ...

Tips for keeping the footer at the bottom center of the page with Bootstrap?

I'm in the early stages of learning how to build a webpage using HTML & CSS, and I've been utilizing the Bootstrap 4.5 framework. One challenge I'm facing is trying to keep my footer with social media icons centered at the bottom of the page ...

Utilizing nested HTML within an HTML tag

Recently, I've been exploring the concept of nested HTML in Bootstrap. While following a tutorial on using Popovers, I encountered the following code; <button id="btn3" type="button" class="btn btn-primary show" ...

How about incorporating two subtly tilted SVGs for a creative twist on navigation backgrounds?

I am in the process of designing the navigation menu for my website and I have a specific vision in mind. I want to create a unique background using two rectangular SVGs that are slightly rotated off axis and overlapping each other, with their edges extend ...

Nothing is being returned when using JQuery AJAX POST

Having trouble identifying the issue, as all that seems to happen is the URL changes to "http://localhost/?search=test" when entering "test", for example. index.php <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquer ...