Setting up breakpoints for nested rows in Bootstrap can be achieved by utilizing the responsive

Currently, I am in the process of learning how to create a responsive website. One thing that has me puzzled is how to set the breakpoints for the content when the screen size changes. Here is what I am aiming to achieve:

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

This code snippet below is only designed for desktop size:

             <div className="row wrapper-about">
                <div className="col-lg-6 col-md-6 col-6">                  
                    <div className="img-box">
                      <img src="/pp1.jpg" alt="foto.jpg" />
                    </div>
                </div>
               <div className="col-lg-6 col-md-6 col-6">
                  <div className="row">
                      <div className="desc-container">
                        <h5 className="text-justify">
                          Content 2
                        </h5>
                      </div>
                  </div>
                  <div className="row desc2-d">
                      <span>
                        Content3                   
                      </span>
                  </div>
                </div>
             </div>

Answer №1

To create this layout without any additional CSS or redundant markup, a simple approach would be to disable flexbox for larger screens and utilize float utilities:

Check out this Codeply example

<div class="container">
    <div class="row d-md-block">
        <div class="col-6 col-md-8 float-left border border-danger c1">
        c1
        </div>
        <div class="col-6 col-md-4 float-left border border-success">
        c2
        </div>
        <div class="col-12 col-md-4 float-left  border border-warning">
        c3
        </div>
    </div> 
</div>

Similar queries have been addressed in the past:

Rearranging responsive Bootstrap 4 grid layout
Bootstrap with different order on mobile version
One tall div next to two shorter divs on Desktop and stacked on Mobile with Bootstrap 4
Bootstrap 4 - Stack 2 columns with 1 large column on the right

Answer №2

If you're working with the Bootstrap grid system, you'll need to include the C3 div twice. Place it once inside the second column of the first row (for larger screens) and again below the first row (for smaller screens). You can then use media queries to toggle the visibility based on the 768px breakpoint to achieve your desired layout...

Check out the code snippet below:

.divC1 {
  border: 5px solid red;
  height: 300px;
}

.divC2 {
  border: 5px solid green;
  height: 150px;
}

.divC3 {
  border: 5px solid yellow;
  height: 150px;
}

@media screen and (max-width:768px) {
  .divC2 {
    height: 300px
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">


<div class="container-fluid">
  <div class="row">

    <div class='col-6 col-sm-6'>
      <div class="row">
        <div class="col-sm-12 divC1"> C1
        </div>
      </div>
    </div>

    <div class='col-6 col-sm-6'>
      <div class="row">
        <div class="col-sm-12 divC2"> C2
        </div>
        <div class="col-sm-12 divC3 d-none d-md-block"> C3
        </div>
      </div>
    </div>

    <div class='col-12 divC3 d-block d-md-none'> C3
    </div>

  </div>
</div>

Answer №3

Here is a code snippet that can assist you:

.c1 { height:200px; outline:2px solid red; outline-offset: -5px; }
.c2 { height:100px; outline:2px solid green; outline-offset: -5px; }
.c3 { height:100px; outline:2px solid yellow; outline-offset: -5px; }

@media only screen and (max-width:768px) and (min-width:200px) {  

       .c1 { height:auto; }
   .c2 { height:auto; }
   .c3 { height:auto;}    

     } 
<meta name="viewport" content="width=device-width, initial-scale=1">
  
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 c1">
C1
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 c2">
C2
</div>

<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 c3">
C3
</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

What steps can I take to prevent Internet Explorer from caching my webpage?

After implementing Spring MVC for Angular JS on the front end, I encountered an issue where logging in with different user credentials resulted in incorrect details being displayed. This problem only occurred in Internet Explorer, requiring me to manually ...

Need assistance posting on Twitter? Utilize PHP for a solution!

I'm attempting to share a user-generated and dynamic URL on Twitter, but I'm having trouble with the encoding... <a href="http://twitter.com/?status=[urlencode('I'd like to borrow this item @neighborrow')].">TWEET THIS REQUE ...

Achieving equal heights for div boxes while aligning list items inside

I have 8 green boxes on my site, each containing an image and either 3 or 4 list items with text only. The issue I'm facing is that the boxes are not of equal height due to two reasons: (1) One box may have an extra list item pushing the rest down, or ...

Displaying a message text upon successful AJAX request

I have a web page with an AJAX request that updates data in the database. After the update, I want to display a message to the user on the webpage confirming that the data has been successfully updated. However, currently, no message is being displayed and ...

Error occurred during SCSS rendering process: [Internal Error: Unable to locate or read the specified file.]

When trying to create a website using scss, I encounter an error every time I save the scss file. Strangely, after saving it multiple times, the file will render properly. Although this issue is minor, it really bothers me. I have searched for a solution ...

JS How can I generate individual buttons in a loop that trigger separate actions?

Currently, I am working with loops in jQuery to create a series of boxes that contain specific values. The problem arises when I try to assign actions to each box based on the values from an array. For example, I want each box to trigger a different alert ...

Ensuring a DIV remains fixed in place for a specific number of scrolls

I'm looking to create a 'Page section' that remains in place while scrolling for a specific distance and then smoothly transitions to the next section. I've attempted to implement this within the child theme without success... Any sugge ...

The problem of undefined icons in Material UI's Stepper StepLabel

Having some trouble incorporating a custom Step Label Icon within the nodes of the Stepper Component provided by Material UI. I want to add an icon to each circle, similar to what is shown in this Material UI demo: https://i.sstatic.net/WLOcS.png However, ...

Nested div within another div, shifting position relative to scrolling (React)

My goal is to create a unique effect where an object falls from the sky as the user scrolls down the page. The concept involves having the object div remain stationary in the center of its parent container, positioned 50 pixels from the top. However, when ...

Automatically navigate to a specific element as the user scrolls down the page

I am attempting to achieve a similar effect as seen on the App Builder Website. When the user reaches the header with the background image/video and scrolls down, the website smoothly transitions to the next div/section. If the user scrolls back up and ret ...

How can we determine if the submit function in HTML5 is returning an error or not?

I have implemented HTML5 validation on my website. <form class="" id="myForm" method="post" action="#" > <input type="text" required /> <input type="submit" /> </form> <div> <input type="button" id="myButton" /></di ...

What is the best way to enlarge a thumbnail using CSS?

Is there a way to resize an image without distortion? I am struggling with resizing a 70px thumbnail image to 200px X 165px while maintaining the aspect ratio. Currently, when I set the width to 200px and height to 165px, it stretches the image. Below is ...

Tips on showcasing a JSON object containing two arrays in HTML using a pair of for loops

I am facing an issue with displaying data from two tables in my PHP script. The personal information is being displayed correctly, but the books related to each person are not showing up. I suspect that my approach might not be efficient enough for handlin ...

Python file is not able to show data on HTML table

I am having difficulty displaying the data retrieved from the database in an HTML table. store.py def book_list(): # Define the query for the DB query = "SELECT * FROM " + DBtable` ## Execute the query mycursor.exe ...

Using values from an appsettings.json file as href variables in an AMP html: a complete guide

Currently developing an AMP website with the URL www-dev.example.com, directing users to a sign-up page. The sign-up page is hosted on an identity server under the subdomain auth.www-dev.example.com. Now, the goal is to deploy the AMP website to a staging ...

What is the method for selecting an li element within a ul list using Selenium in Python?

My goal is to automate the process of clicking on 'National Data' on a specific website using the Selenium package in Python. The website I am referring to can be found at . Although I attempted to achieve this automation, I encountered difficul ...

Using media queries in CSS to create responsive designs

<link type="text/css" rel="stylesheet" media="only screen and (max-device-width: 480px)" href="/assets/css/phone.css" /> <link type="text/css" rel="stylesheet" media="only screen and (min-device-width: 768px)" href="/assets/css/tablet.css" /&g ...

Discover how to retrieve the calculated percentage within CSS with the assistance of jQuery specifically designed for Webkit

I'm currently working on a simple sliding animation. However, the div that slides in is utilizing percentages for its width and right positioning. The issue arises specifically in Webkit browsers. When using jQuery to retrieve the value, it returns t ...

Check the radio box corresponding to the adjacent label

As a hobby, I have been exploring ways to automate questionnaires that I used to manually deal with for years. It has always intrigued me how best to streamline this process, and now I am taking the opportunity to indulge in my passion and enhance my JavaS ...

Achieve hidden and visible elements using CSS without redundancy

Is there a way to hide a div on specific devices and show it on others without resorting to duplicating the code or using CSS hacks? This is my current approach: <div class="container"> <div class="row"> <div class="col-md-8 d-none d- ...