What is the best way to optimize Bootstrap 5 grids for mobile responsiveness?

Within my portfolio, I have a projects section that switches between having the description on the left with an image on the right and vice versa. Despite my efforts to make it responsive, I'm struggling to figure out how to ensure the image appears above the text on each project when viewed on a smartphone.

Here is the HTML for the projects section:

<section id="projects">
        <div class="container">
          <div class="row projects">
              <h1>My Projects</h1>
            <div class="col project-desc-left">
              <h2>Tindog</h2>
                <p>A landing page for the Tindog app - a unique take on dating apps. Built using Bootstrap 5 and HTML/CSS with Bootstrap grids.</p>
                <i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <i class="fab fa-bootstrap"></i><br>
                <a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/TinDog-WebDevBootcamp/" role="button" target="_blank">Live Site</a>
                <a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/TinDog-WebDevBootcamp" role="button" target="_blank">Github Repo</a>            </div>
            <div class="col col-lg-6 col-sm-12 project-img-right">
              <img class="project-img" src="assets/tindog.png">
            </div>
          </div>
          <div class="row projects">
            <div class="col">
              <img class="project-img" src="assets/nftcard.png">
            </div>
            <div class="col project-desc-right">
              <h2>NFT Preview Card</h2>
                <p>A preview card page created using HTML/CSS.</p>
                <i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> <br>
                <a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/nft-preview-card-component-main/" role="button" target="_blank">Live Site</a>
          <a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/nft-preview-card-component-main" role="button" target="_blank">Github Repo</a>            </div>
          </div>
          <div class="row projects">
            <div class="col project-desc-left">
              <h2>3-Card Column</h2>
                <p>A preview card showcasing vehicle options designed with HTML/CSS.</p>
                <i class="fab fa-html5"></i> <i class="fab fa-css3-alt"></i> </i><br>
                <a class="btn button primary-button mr-4 live-site-btn" href="https://kiannaamaya.github.io/3-column-preview-card-component-main/" role="button" target="_blank">Live Site</a>
                <a class="btn button secondary-button mr-4 github-btn" href="https://github.com/kiannaamaya/3-column-preview-card-component-main" role="button" target="_blank">Github Repo</a>
            </div>
            <div class="col project-img-right">
              <img class="project-img" src="assets/3colcard.png">
            </div>
          </div>
        </div>
      </section>

I attempted to utilize col-xs-12 in Bootstrap 5 for responsiveness, but it resulted in undesirable outcomes and distorted the desktop view. The layout looks satisfactory on a laptop, but other screen sizes are problematic.

This is the CSS styling used:

/* Projects */
    
    #projects {
        width: 100%;
    }

    #projects h1 {
        text-align: center;
    }

    .projects {
        margin-left: 0;
        
    }

    .project-img{
        width: 300px;
    }
    
    .project-desc-left {
        margin: 5rem;
        width: 320px;
    }
    
    .project-desc-right {
        
    }
}

Despite spending several days tweaking the code, minimal progress has been made.

This showcases the laptop view of the projects section

This displays the mobile view of the projects section

Answer №1

Utilizing Bootstrap 5's Column Ordering feature allows you to arrange content without the need for additional CSS. By applying specific classes to your columns, they will display in the specified order on the page regardless of their position in the HTML structure.

Here is a general guide on how to use it:

.order-1
.order-2
.order-3
.order-4
.order-5

If you want to control the ordering based on screen size, you can use classes like .order-sm-1 (for small screens), .order-md-2 (for medium screens), .order-lg-3 (for large screens), and so on.

In addition, you have options to make items unordered or specify them as ordered first or last. More detailed information can be found in the official Bootstrap documentation here.

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

Include a blank area on the right side and a duplicated image on the bottom right using Bootstrap

Let's set the scene: This screenshot showcases www.dreamstreetentertainment.com, a site that is still a work in progress but is already live. Don't inquire about it. The client insists on this setup. Essentially, I have an empty space to the rig ...

Guide on creating a darkening effect for lights

Seeking assistance on how to create a light-off effect when clicking on any of my textboxes. I discovered this concept on the following website: What I aim to achieve is that upon clicking a specific textbox, it will be highlighted. Upon clicking the sam ...

Is it better to apply the font-family to the body or to the html element?

Is it more appropriate to specify the font-family CSS property on the html element or the body element? html { font-family: sans-serif; } or body { font-family: sans-serif; } I've looked into this issue online, but there doesn't seem to ...

What are the tips for aligning this button perfectly on the page, despite being centered in a computer's resolution?

Dealing with Responsive Design Hey there! I'm having an issue with my Bootstrap layout. I managed to center a button, but when I adjust the resolution or make it smaller, the button wraps and shifts to the right. Can anyone help me figure out what we ...

The asynchronous ajax request is leading to a browser freeze

In the HTML page, I have two sets of a and p elements that are initially set to display:none. At the bottom of the page, there is a function being called with their respective ID's and values, which will enable one of them based on certain conditions ...

Organize AngularJS ng-repeat using dictionary information

I'm dealing with a dictionary consisting of key-value pairs, which looks something like this: data = { "key1": 1000, "key2": 2000, "key3": 500 } My goal is to display this data in a table using AngularJS. One way I can achieve this is b ...

Display an empty string when a value is NULL using jQuery's .append() function

To set an HTML value using the .append() function, I need to include AJAX data values. If the data set contains a null value, it will show as 'null' in the UI. I want to remove that 'null' and display it as blank. However, I can't ...

Namespace SyndicationElementExtension refers to

I'm trying to achieve the following output: <someNSalias:full-text>Good news everyone!</someNSalias:full-text> This is the code I have written: var element = new SyndicationElementExtension(field.Name, field.HasNamespace ? RssNs : strin ...

jQuery slide adjusts the width of the slide as it transitions

The script is running smoothly. Check out the jsFiddle here The issue lies in its width adjustment when sliding (clicking "here"). It seems to be cutting off the width related to a 100px margin-left in #slider. Why does it seem to "jump" and how can this ...

Creating CSS-style overlayed images that are resizable

I have a collection of images all the same size, and I want them to be overlaid on top of each other. I've tried setting the position of the images to absolute, but this causes an issue with the container not adjusting its size accordingly. Additiona ...

Is it possible for search engines like google to index Javascript content that is stored within divs and loaded onto the page?

My website utilizes JavaScript to dynamically add content to div elements, like so: <script> //This content is generated by PHP var contents = [ "Item 1", "Item 2" ]; //Display the first item document.getElementById( "item" ).textCo ...

What is the best method for flipping the sequence of elements in media queries?

I am facing an issue with two divs, left and right, on my webpage. When the screen size is less than 500px, I want the left div to move to the bottom and the right div to move to the top. Essentially, I need to swap the positions of these divs in the DOM. ...

What is the best way to align a button with a title on the right side of a page?

Is it possible to align my button to the top right, at the same height as the title in my design? Here is an example: view image here This is what I have achieved so far: view image here I suspect there may be an issue with my divs. The button doesn&a ...

Ways to subtly adjust the edges of text in a design

https://i.stack.imgur.com/sr4PF.pngIs there a way to adjust the border of text that already has a border applied? I have successfully created the text with the border using the following CSS: h1 { font-size: 35pt; text-align: center; font-family: ...

What is the best way to retrieve the current value of an *ngFor loop upon button click?

I have been attempting to retrieve the data.login value of the data item that the user has clicked on the avatar image. Despite my efforts, I have not been able to successfully achieve this through various methods found online. How can I access the current ...

The Zurb Foundation grid system is causing issues when trying to implement vertical tabs

My vertical tabs are giving me trouble when I try to nest grid or block elements, causing everything to overflow outside the element. For example, in the image below, the numbers 1,2,3 should be in the right section. <div class="row"> <div class ...

Applying CSS dynamically to a mat-cell in Angular 6

In my material table, I need to apply specific CSS classes based on the content of the cell. https://i.sstatic.net/YN6EO.png These are the CSS classes that I am using .status-code{ flex: 0 0 10% !important; width: 10% !important; } .status-code- ...

Place an image in the middle of a div

Here are a few images for you to consider: <div class="builder-item-content row"> <div class="twelve columns b0" style="text-align:center;"> <ul class="upcoming-events"> <li> <a href="http://www.padi.com/scub ...

Toggle a button with javascript

My setup involves two switches: <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="switch1" checked> <label class="onoffswitch-label" for="switch1"> <span class="onoffswitch-inner"></span> <span ...

What is the method for increasing the left margin of the back button on the default header in React Native?

My attempt to increase the space on the back button from the left side of the header in my React Native code has been unsuccessful. headerStyle: { paddingLeft: 60 } https://i.stack.imgur.com/0RFb0.png I also experimented with adding margin ...