Achieving Vertical Stacking and Responsive Scaling for Row and Column Containers on Mobile View Using HTML, CSS, and Bootstrap 4

Utilizing the Bootstrap grid system to organize text boxes in a 2 by 2 layout on a webpage. The desktop view displays the content in rows and columns effectively, but it would be beneficial to have an easy way to adjust the width.

However, the problem arises when viewing the webpage on a mobile device. The content does not scale proportionally, causing the boxes to shrink and become difficult to read.

The ideal solution is for the boxes to automatically resize and stack vertically on top of each other when viewed on a mobile device. This ensures that the content is easily readable on a phone.

Instead of: [A][B] [C][D]

This is how they should appear on mobile:

[A]

[B]

[C]

[D]

What is the best way to achieve this? Here is a visual reference:

Mobile View:

https://i.sstatic.net/mZPwS.png

HTML

<html>
        <head>
        <title>site</title>
        <link rel="stylesheet" href="style.css">
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">   
        </head>
        <body>
            
            <div class="container"> <!--bootstrap class-->
                <div class="services">
                    <h1>Our <span>Services</span></h1>
                    <p>text here</p>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="service-box">
                            <i class="fa fa-smile-o" aria-hidden="true"></i>
                            <h3><span>Box A</span></h3>
                            <p>
                                Text
                            </p>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="service-box">
                            <i class="fa fa-eye" aria-hidden="true"></i>
                        <h3><span>Box B</span></h3>
                        <p><b>List:</b><br>                   
                            1<br>
                            2<br>
                            3<br>
                            4<br>
                            5<br>
                            6<br>
                            7<br>
                            8<br>
                            9<br>
                            10
                        </p>
                        </div>
                    </div>

                </div>
                    <div class="row" style="margin-top: 35px">
                    <div class="col-md-6">
                        <div class="service-box">
                        <i class="fa fa-pencil"></i>
                        <h3><span>Box C</span></h3>
                        <p>
                            I<br>
                            II<br>
                            III<br>                       
                        </p>

                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="service-box">
                        <i class="fa fa-shield"></i>
                        <h3><span>Box D</span></h3>
                        <p>
                            Defender<br>
                        </p>
                    </div>
                    </div>
                </div>
                <a href="#" class="home-button"><i class="fa fa-home" aria-hidden="true"></i> HOME</a>
            </div>
    </body>
    </html>
    

Answer №1

Check out this code for a div with the class "col-md-12"

 <div class="col-md-12">

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

"Enhancing Forms with Multiple Event Listeners for Seamless Sub

I'm working on creating a countdown timer with 3 buttons for controlling the timer: start, cancel, and pause. The timer itself is a text input field where you can enter a positive integer. I need to use core JavaScript, not jQuery Start Button: Init ...

The basic CSS container fails to properly align its elements as intended

Recently, I created a CSS div using Bootstrap and added some custom styling. You can check out the fiddle for a live demo of the code: https://jsfiddle.net/w9gyc0t5/. Here's the actual code: <!-- Bootstrap docs: https://getbootstrap.com/docs -- ...

What is the best method to restore a table cell to its original width?

Here's a quick overview of the issue I'm facing: http://jsfiddle.net/k2Pqw/4/ Once I adjust the red td width, I'm struggling to revert it back to its original size. Setting it at 25% doesn't dynamically adjust like the other tds, it r ...

The Faux-Dynamic News Feed on a stationary website

As I work on revamping my employer's static website, it has become clear that a news section needs to be integrated. The site is being built using the Bootstrap 3.0 framework. My plan is to implement the following strategy: I aim to have a JavaScrip ...

Dropdown boxes that fetch data from a database in a cascading manner

Currently, I am working on creating two dropdown boxes that will be dynamically populated from a database using PHP and Ajax. The first dropdown menu will have only one option available, but selecting it should trigger the population of the second dropdown ...

Brainstorm: Creative ways to showcase excess content within a div

I'm struggling to find a suitable title for this issue. Essentially, I have a box-shaped div that expands into a rectangle and reveals content when clicked. The problem arises when I animate the div's width during expansion. Instead of positioni ...

How to Access a PHP Variable within a JavaScript Function Argument

.php <?php $timeArray = [355,400,609,1000]; $differentTimeArray = [1,45,622, 923]; ?> <script type="text/javascript"> var i=0; var eventArray = []; function generateArray(arrayName){ eventVideoArray = <?php echo json_encode(arrayName); ...

Validation is performed on the Bootstrap modal form, ensuring that the modal is only loaded after the

In order to provide a better understanding of my website's file structure, I would like to give an overview. The index.php file dynamically adds many pages to my website. Here is the code from index.php: <?php include ('pages/tillBody.php ...

Modifying the color of a variety of distinct data points

There was a previous inquiry regarding Changing Colour of Specific Data, which can be found here: Changing colour of specific data Building upon that question, I now have a new query. After successfully changing the 2017 dates to pink, I am seeking a way ...

Looping Issue in WordPress

Here is the code snippet I am currently working with: <?php query_posts("order=ASC&cat=4"); ?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <?php if(get_post_custom_values("show") != NULL): ?> ...

How to adjust animation timing for various elements during a CSS 3D flip with a delay?

Here is a CSS flip setup that I have been working on in this fiddle: http://jsfiddle.net/6r82fzk6/ The Goal: I am trying to achieve a slower transition for the back element compared to everything else. The idea is to have the child element of the back fac ...

Using JQuery to visually enhance the menu selection by displaying an image and altering the background color upon hovering

Hello fellow JQuery/Javascript beginners! I recently put together a menu and wanted to add some interactive elements. Specifically, I want the background color to change when a user hovers over an item (simple enough with CSS), but I also want to include a ...

JavaFX: Achieving uniform size for multiple circles

I have a seemingly straightforward question that has been puzzling me. I am looking to define multiple circles in my FXML file; 10 of these circles should have a radius of 10px, while 20 others should have a radius of 6px. I want to establish the size at o ...

Styling a div to wrap around an image

I'm working with an image element that has the style attribute set to style='width:40%;height:40%'. My goal is to add a div around this image that will automatically adjust its size to wrap around the image. However, when I try inserting the ...

eliminating the left and right margins in WordPress bootstrap

I am currently working on a Wordpress website using the music macho theme. The main website (https://techtreetweb.000webhostapp.com/) consists of full-width pictures. However, when I try to add extra pages, those pages always have a white margin to the l ...

The function of jQuery's .prop('defaultSelected') appears to be unreliable when used in Internet Explorer 9

Below is the code I am currently using: $selects = $('select'); $selects.val( $selects.prop('defaultSelected')); The purpose of this code is to reset the values of all select elements on my webpage. However, I am facing an issue in IE ...

Having trouble with your jQuery image slider?

As a newcomer to jQuery, I have been experimenting with it to gain some experience. I recently tried to integrate a jQuery image slider from slidesjs.com into my local website but unfortunately, it is not functioning as expected. Additionally, I would lik ...

How to create centered striped backgrounds in CSS

Attempting to achieve a background similar to the one shown Can this be accomplished using CSS? ...

Utilizing the jQuery slideToggle method on the specified target element

I'm encountering an issue with jQuery slideToggle, and here's the code I have: $(".dropdownmainmenu").click(function(){ $(this).children(".showmenu").slideToggle(); $(this).toggleClass("activemainmenu"); $(this).find(".showarrowmainmen ...

Experiencing discrepancies in pixel height while conducting tests using Nightwatch

Let me start by sharing some details about my machine setup: Operating System: CentOS 7 Graphics Drivers: kmod-nvidia (dedicated GPU) I am currently testing a webpage using Nightwatch, and one of the requirements is to ensure that a background image&apo ...