Steps to create five equally sized columns for desktop and four for mobile using Bootstrap 4

I successfully implemented 5 equal columns in Bootstrap for my responsive design using container-fluid. However, I encountered an issue when trying to hide one column at lower resolutions, which I also managed to solve. Now, the challenge lies in creating two rows with 4 equally sized columns each on mobile view. Unfortunately, my current code is not achieving this desired layout. Instead, it breaks down into a row with 3 columns and another row with only 1 column, mirroring the size of those 3.

Below is my existing Bootstrap code;


      <div class="container-fluid content">
        <div class="row">
          <div class="col col-xs-6">
             <div class="stats">
               <div class="big">111</div>
               <div class="small">COLUMN 1</div>
             </div>
           </div>
           <div class="col col-xs-6">
             <div class="stats">
               <div class="big">222</div>
               <div class="small">COLUMN 2</div>
             </div>
           </div>
           <div class="col d-none d-md-block">
             <div class="stats">
               <div class="big">333</div>
               <div class="small">COLUMN 3 (DISAPPEARS ON LOW RES)</div>
             </div>
           </div>
           <div class="col col-xs-6">
             <div class="stats">
               <div class="big">444</div>
               <div class="small">COLUMN 4</div>
             </div>
           </div>
           <div class="col col-xs-6">
             <div class="stats">
               <div class="big">555</div>
               <div class="small">COLUMN 5</div>
             </div>
           </div>
        </div>
      </div>

Any insights on what I may be overlooking? Thank you.

Answer №1

col-xs-*- has been deprecated in Bootstrap 4 beta. To create columns with equal width on sm and up, use col-sm, and for 50% width columns on mobile (xs), use col-6

Visit this link for reference

<div class="container-fluid content">
    <div class="row">
        <div class="col-sm col-6">
            <div class="stats">
                <div class="big">111</div>
                <div class="small">COLUMN 1</div>
            </div>
        </div>
        <div class="col-sm col-6">
            <div class="stats">
                <div class="big">222</div>
                <div class="small">COLUMN 2</div>
            </div>
        </div>
        <div class="col d-none d-md-block">
            <div class="stats">
                <div class="big">333</div>
                <div class="small">COLUMN 3 (DISAPPEARS ON LOW RES)</div>
            </div>
        </div>
        <div class="col-sm col-6">
            <div class="stats">
                <div class="big">444</div>
                <div class="small">COLUMN 4</div>
            </div>
        </div>
        <div class="col-sm col-6">
            <div class="stats">
                <div class="big">555</div>
                <div class="small">COLUMN 5</div>
            </div>
        </div>
    </div>
</div>

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

Expanding Table Rows in DataTables

Currently, my DataTable has hidden child rows to display additional information. Each parent row represents a gift card, while the hidden child rows show a log of that gift card. A gift card can have multiple logs. For example: Gift Card 1: 0 rows; the ...

Tips for designing a unique custom scrollbar

I'm in need of some CSS expertise to help me create a custom scroll bar that resembles the one shown in the image. The key requirement is for the background to be transparent, although I've temporarily positioned it against a green backdrop. ...

Header with a list and an accompanying image using HTML and CSS

Struggling to incorporate a header featuring a list and a small logo in the top right corner of the page, seamlessly integrated with the header lines. The first image link reflects my desired result while the second image shows where I'm encountering ...

Remove old photo when uploading new one in Django

I'm currently working on a user profile feature that allows users to upload profile pictures. The uploading process is functioning correctly, but I'm encountering an issue where the old photo is not replaced when a new one is uploaded. I'm u ...

How can I generate an SQL query using the <options> tag and display the result through echoing

I am in the process of creating a page that will show users the cost of repairing their damaged mobile phone. With a database containing all the pricing information for various phone models and issues, I need to figure out how to display the final price af ...

Lightbox2 is looking to reposition the caption to the right of the image

Can anyone help me understand how to move the caption, found in data-title, from underneath an image to the right of the image? I'm not very familiar with HTML/CSS, but it looks like the image is enclosed within a div called .lb-outerContainer, and t ...

Displaying a list within a circle that elegantly animates, and then, after two full rotations, magically morphs

Can icons be displayed in a circle and after 1,2 rotations, revert back to the list view? https://i.sstatic.net/p4Jxm.png If so, when it forms after 1,2 rotation, it should resemble a line. https://i.sstatic.net/uJW24.png In summary, looking for a CSS3 ...

Pressing the submit button will not successfully forward the form

I've encountered an issue with my submit buttons - when I click on them, nothing happens. They were functioning properly before, but now they seem to be unresponsive. What could be causing this problem? <form id="contact" name="updateorder" acti ...

What is the process for retrieving matched information from a drop-down menu in HTML?

Is there a way to retrieve data from angularjs like this: This is the list of data I need to access: $scope.orderStatus = [ { os: 'Open', value: 1 }, { os: 'Completed', value: 2 }, { os:'Cancelled',value: 3 }, ...

"Mastering the art of underlining individual components in React with the power of

Hey there, I'm having some issues working with the CSS for my component. I've created a joke component that has joke and punchline props. The issue is that when it appears in the compiler, my joke component (which I call twice) only shows up as t ...

Is there a way to remove the excess white space beneath my content without resorting to using overflow-y: hidden?

I am struggling to eliminate the excess white space below the body of my web page in order to make it fit perfectly within the view of a web browser. Adding height helps with vertical alignment but leaves unwanted white space. I need a solution that doesn ...

What is the best way to obtain SAPUI5 Explored designs?

I am working on implementing a sap.ui.Table in my project, similar to the one showcased in the SAPUI5 Explored app. The table I am trying to create should allow for multi-selection of items using checkboxes on the left side. However, after downloading th ...

JavaScript form with radio buttons

I'm completely new to JavaScript and I'm attempting to create a basic script that will show one form when a radio button is checked, and another form when the second radio button is clicked (with no form displayed when neither is selected). I kno ...

Embedding a picture logo within a CSS-designed content box

I am trying to create a unique layout for my website that reveals content using labelled radio buttons, without the use of scripts. Instead of using <a href='#'>, I want to achieve a specific layout like the one shown in this example. When ...

Error message encountered: "Attempted to serve a new HTML file but received the 'Cannot set headers after they are sent to the client' error."

I'm a beginner in NodeJS and I'm currently working on enhancing a sample project that utilizes the Spotify API and Express. In this project, users are required to authenticate on the homepage, after which they should be directed to a different HT ...

Equalizing the width of the border to match the width of the text

After designing a menu using a website builder with custom CSS, I found that the HTML code generated automatically by the builder needed some tweaking. Upon inspecting the code, I discovered the following structure: <div class="elementor-container elem ...

Apply a class using [ngClass] based on an HTML condition within the local scope

In the past, I have utilized [ngClass] to assign classes based on the Boolean value of a variable in the JavaScript/TypeScript. However, I am now curious if it is achievable to apply [ngClass] based on a local HTML boolean value instead? For example: < ...

Prevent dragging functionality after being dropped onto a droppable area

I am currently working on a drag and drop project and have encountered a minor issue. My goal is to disable the draggable item after it has been dropped onto the droppable area. I have created a function called disableDrag, but I am receiving an error in t ...

What might be the reason behind Chrome occasionally not updating the page when I resize the browser window?

Currently, I am in the process of developing a responsive design site prototype. Everything is going smoothly except for one peculiar issue that only seems to occur in Chrome. Sometimes, when expanding the window, the browser appears to get stuck between s ...

Issues with the execution of Jquery function

Hey guys, take a look at my code: //Additional Jquery codes // display_popup_crop : revealing the crop popup function display_popup_crop(link) { alert("show_popup_crop function is triggered!"); // changing the photo source $('#cropbox&a ...