What is the best way to arrange four divs in a row on a mobile device that is responsive?

I am facing an issue with displaying 4 divs of equal size on my website. In desktop view, they appear side by side but in mobile view, they stack on top of each other. I have tried using display: flex; and bootstrap classes like col-3, col-sm-3, col-md-3, col-lg-3, but the layout is still not responsive.

.container-fluid{
    min-width: 290px;
    max-width: 1500px;
    margin: 15px 10px;
    text-align: center;
    /* border: 0px solid #777; */
    /* border-radius: 5px; */
}
.content{
    font-family: 'Hammersmith One', sans-serif;
    margin: 10px 0;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    cursor: pointer;
    position: relative;
    

}
.content .box{
    min-width: 200px;
    margin: 8px;
    /* border: 0.5px solid #ccc; */
    padding: 1px;
    border-radius: 10px;
    letter-spacing: 1px;
}
<div class="container-fluid mt-5">
            <div class="row">
            <div class="col-md-10 col-12 mx-auto">
                
                

                        
                <div class="content col-12 col-sm-12 col-md-12 col-lg-12">
                    <a class="page" id="confirmed" tabindex="0">
                        
                        <div class="box confirmeds nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                            <p>Confirmed</p>
                            <i class='bx bx-plus'>550</i>
                            <h3>//data came from API</h3>
                            
                        </div>
                    </a>
                    <a class="page" id="active" tabindex="0">
                        
                        <div class="box actived nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                            <p>Active</p>
                            <h6></h6>
                            <h3>//data came from API</h3>
                            
                        </div>
                    </a>
                    

                    <a class="page" id="recover" tabindex="0">
                        
                        <div class="box recovereds nav-item col-3 col-sm-3 col-md-3 col-lg-3">
                            <p>Recovered</p>
                            <i class='bx bx-plus'> 1500</i>
                            <h3>//data came from API</h3>
                            

                        </div>
                    </a>
                    

                    <a class="page" id="dieds" tabindex="0">
                       
                        <div class="box deathss nav-item col-                           3 col-sm-3 col-md-3 col-lg-3">
                            <p>Deaths</p>
                            <i class='bx bx-plus' >502</i>
                            <h3>//data came from API</h3>
                            
                        </div>
                    </a>

How can I make them align side by side? I have attempted to use @media queries without success. Can someone suggest some media queries to adjust font sizes for a specific width (mobile view)? Below are some screenshots for reference :- https://i.sstatic.net/CzakN.jpg

https://i.sstatic.net/JJf38.jpg

https://i.sstatic.net/aamrc.jpg

Answer №1

This is how you can utilize it -

<div class="col-xs-12">
  <div class="col-xs-3">Section 1 </div>
  <div class="col-xs-3">Section 2 </div>
  <div class="col-xs-3">Section 3 </div>
  <div class="col-xs-3">Section 4 </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

Adaptable div arrangement

Currently, I am working on a layout that includes a toolbar and a main div. In my design, the positioning of the toolbar should change based on the window's dimensions. If the Y axis is smaller than the X axis, the toolbar needs to be on the left side ...

Preserving the Selected Date on the Calendar Even After the PHP Variable is Passed

I am currently using the calendar code below with a slight modification that I implemented. However, I have encountered an issue where when I select a date, the calendar successfully highlights the selected date. But once I pass this selected date along ...

Uncovering the Mystery Behind the Repetitive Execution of useEffect in Next.js

I am working on a Time Tracking feature for my Next.js application. In the ./app/components/TimeTracking.tsx file, I have implemented the following component: 'use client'; import React, { useEffect, useState } from 'react'; import { u ...

Browsing a Table in Vue

I'm currently building a Vue application that showcases a collection of quotes and includes a search feature for filtering through the data. It seems like I might not have properly linked the function to the correct element. I've added a v-model ...

Transition within Bootstrap navbar is not as smooth as desired

My bootstrap navbar HTML code is as follows: <nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgb(50, 50, 50)"> <button class="navbar-toggler" type="button" data-toggle="col ...

Why are my AngularJs elements not appearing in the print dialog window?

Whenever I try to open the print Dialogue on a specific page, all I'm seeing is a blank screen. The majority of the content on this page consists of AngularJS elements. To trigger the print dialogue, I use the following code: <a href=""onclick="wi ...

Modify background image upon hovering using AngularJS

I cannot seem to make the background images of my divs change. Despite trying various options, none of them have been successful. Here's an example of my code: <div ng-controller="mainController" class="main"> <div ng-repeat="land in lan ...

Angular Custom Pipe - Grouping by Substrings of Strings

In my Angular project, I developed a custom pipe that allows for grouping an array of objects based on a specific property: import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'groupBy'}) export class GroupByPipe impleme ...

Mac OS reports an Illegal instruction: 4 error when running NodeJS

Each time I try to execute my program, it gives me an Illegal instruction: 4 error without any clue as to why. The code snippet in question: glob('/path/music/*.mp3', function(error, files) { for(var i = 0; i < files.length; i++) { songs ...

Modifying the page header content using JavaScript

There's this snippet of code that alters the image on another page: <div class="imgbx"> <button onclick="window.location.href='index.html?image=images/xr-black.jpg&tit=XR-black'" >Invisible ...

An issue related to AngularJS and the injection of ui-bootstrap components has been encountered

I'm encountering an issue with injection errors in my code, and unfortunately, the debugger in Firefox isn't providing much help. Here are snippets of the code: This is the Controller file causing the error: App.controller('ModalInstanceCt ...

Transferring Object Information from AJAX to PHP

When attempting to send data to a PHP file for database storage, I am not receiving any response. If a checkbox is checked, the [obj][idCheckbox] value is set to 1; otherwise, it is set to 0. This is the file responsible for sending the data: var i=0; v ...

Utilizing Next.js Image Component to Apply CSS for Width and Height Settings

Currently, I am utilizing the Image component provided by Next.js, which requires setting specific width and height values. To address this, I am incorporating Tailwind CSS utility classes to establish the desired dimensions. https://i.sstatic.net/A28fB.j ...

Issue with Ionic ng-click not triggering

I am currently experimenting with an Ionic application that utilizes a Firebase backend. The issue I'm facing is that the ng-click="loginUser(user)" function does not seem to be triggering. When checking the console, it only displays Signed Out from ...

Angular 4 showcases the information stored within this dataset

The data returned from an API to my Angular 4 application is not to my liking. Here is an example of the JSON, where I am only interested in the coin and its price: Goal is to display this data on the page: Coin Price BTC $4,281.28 ETH $294.62 ...

Numerous JSON entities

Curious to know if it's achievable to load more than one JSON file with just a single jQuery.ajax() call. Or do I have to make separate calls for each file? Warm regards, Smccullough ...

Steps for resolving the "endless redirection loop" issue in Sharepoint

I am currently learning Javascript and working on setting up a multi-language Sharepoint site. I am trying to implement a code into each page that checks the user's email and the language in the URL (Portuguese or Spanish) and then redirects according ...

A guide on understanding tab-formatted text in a textarea using JavaScript (Vuejs)

Trying to decipher a text that has been copied into a Word table, the formatting is very confusing. I am looking to extract the rows as objects in an array, with the columns serving as properties of each object. I would like to accomplish this using Vuejs ...

Fade one element on top of another using Framer Motion

Looking to smoothly transition between fading out one div and fading in another using Framer Motion, but facing issues with immediate rendering causing objects to jump around. Example code snippet: const [short, setShort] = useState(false); return ( ...

Tips for integrating Apache Solr with Cassandra without using DataStax Enterprise (DSE)

Embarking on a new project, I find myself utilizing Cassandra as the chosen DBMS, with Apache Solr serving as the search engine and Node.js powering the server scripting language. While I am well-versed in Node.js, Cassandra and Solr are unfamiliar territ ...