What is the best way to achieve this grid layout using Bootstrap 4 grids?

I'm struggling to achieve the desired layout using Bootstrap 4 grid. In the desktop view, images are in positions 2, 3, and 6, while the rest are text.

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

This is how the site should look on mobile.

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

Here is the HTML code:

<section class="col-12">
<div class="row">
    <div class="col-12">
        <div class="row">
            <div class="col-12 col-sm-6 order-2 order-sm-1">
                <div class="row">
                    <div class="col-12">
                        <p></p>
                    </div>
                </div>
            </div>
            <div class="col-12 col-sm-6 order-1 order-sm-2">
                <img src=""/>
            </div>
        </div>
    </div>
    <div class="col-12">
        <div class="row">
            <div class="col-12 col-sm-6">
                <img src=""/>
            </div>
            <div class="col-12 col-sm-6">
                <div class="row">
                    <div class="col-12">
                        <p></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-12">
        <div class="row">
            <div class="col-12 col-sm-6 order-2 order-sm-1">
                <div class="row">
                    <div class="col-12">
                        <p></p>
                    </div>
                </div>
            </div>
            <div class="col-12 col-sm-6 order-1 order-sm-2">
                <img src=""/>
            </div>
        </div>
    </div>
</div>
</section>

Check out the project here: . To adjust the spacing for elements 4, 5, and 6 in the CSS, I used:

position: relative;
top: -25%;

Although this gave me the desired result, it resulted in a large gap at the bottom. Any suggestions on how to modify my Bootstrap classes to achieve the desired layout? I'm new to this.

EDIT: After trying various solutions, I discovered that using CSS grid provided more flexibility in this scenario, as the HTML element positioning was fixed and Bootstrap 4 doesn't support such mixing.

Answer №1

Consider utilizing CSS Grid, a contemporary tool that supersedes flexbox and outdated CSS techniques. With CSS Grid, you have the capability to create any desired layout in a two-dimensional format.
It offers unparalleled versatility and is relatively simple to grasp.

Answer №2

Hey, have you considered utilizing the bootstrap fluid container? It can help you achieve the desired result you are looking for. Check out this link for more information: https://getbootstrap.com/docs/3.4/css/

Answer №3

The grid system in Bootstrap is designed using display:flex flex-direction:column

If you want to customize the styling, you'll need to use additional CSS!!!

It's as straightforward as that.

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

The runtime is experiencing difficulty in loading the Bootstrap files

File Structure in eclipse The issue is that the CSS files are not loading at runtime, causing me to lose the design I created. Below is my code for the login page. When clicking on the links for the CSS files, they open in the Eclipse IDE instead of load ...

Ensure that the child div remains at the bottom of the parent div

I'm trying to make sure that the subfooter div stays at the bottom of the childbox div like a footer. You can see the code on this jsfiddle link <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <title ...

Arrange blocks within bootstrap columns using grid css

I have a layout with two columns, each containing two blocks Currently, the mobile order is: 1 2 3 4 But I want it to be: 3 1 2 4 I attempted to use CSS grid but I am unsure how to move block 3 out of column 2. Here's the code snippet: body { ...

CSS transform: applying the same CSS to multiple divs results in a variety of different outcomes

I am working on creating multiple parallelograms with the same skew aligned horizontally. While the first one looks perfect, additional divs seem to increase the skew more and more. I even attempted this using images and applying transform: rotate() but en ...

Learn the method for switching between exclusive visibility using Bootstrap class toggles

I've set up a jQuery function that toggles the visibility of different divs when clicking on folder icons: $(document).ready(function() { $("#techfolder").click(function(){ $("#txt").toggleClass("d-none"); }); $("#persfolder").click(functio ...

The current layout of the div is hindering the ability to switch from vertical scrolling to horizontal scrolling

I'm currently utilizing this scroll converter tool to transform vertical scrolling into horizontal scrolling. However, despite correct script inclusion and initialization, the conversion is not working as expected. It seems like there might be an issu ...

Using Angular, you can easily add a <div> dynamically to all elements that share a class

In order to implement a solution, I am tasked with adding a new div element with the class '.cart-list-value .delete-product', which will contain a background image, to all elements that have the class .cart-list-item. Although I successfully man ...

none of the statements within the JavaScript function are being executed

Here is the code for a function called EVOLVE1: function EVOLVE1() { if(ATP >= evolveCost) { display('Your cell now has the ability to divide.'); display('Each new cell provides more ATP per respiration.'); ATP = ATP ...

Transitioning the Background Image is a common design technique

After spending hours trying to figure out how to make my background "jumbotron" change images smoothly with a transition, I am still stuck. I have tried both internal scripts and JavaScript, but nothing seems to work. Is there any way to achieve this witho ...

In a grid container, a child element utilizing `overflow-y: auto` will not be able to scroll

<script src="https://cdn.tailwindcss.com"></script> <div class="h-screen grid grid-rows-[auto,1fr]"> <div class="bg-slate-300 h-24 flex items-center px-4"> <h1 class="text-3xl">Navbar</h1> </div> <div ...

Angular's scope allows for the application of CSS classes exclusively to the first div element

Every 2 seconds, a JavaScript function is being called that updates a specific div on the view when a certain condition is met. <div id="ball_{{ballIndex}}">{{ball}}</div> This is controlled by the ng controller. var myCounter = 0; ...

The combination of HTML, CSS, and vertical text margins is essential for creating visually

Looking for some guidance on how html text and margins work? If there's a good online reference you can point me to, I'd greatly appreciate it! I'm currently struggling with setting precise margins for text. In the example below, there&apos ...

Enhancing WordPress Icons for Parent and Child Elements

I am seeking to customize icons on a WordPress website. The site contains a variety of product categories, including subcategories. https://i.sstatic.net/sTm1O.png My goal is to display one icon for parent categories and a different icon for child catego ...

Using a MySQL statement within a conditional statement

Looking to modify this code to display different information based on the values retrieved, here is the current code: $sql_doublecheck = mysql_query("SELECT * FROM adminpage WHERE setting='main' AND close_site='1'"); $doublecheck = mys ...

Utilize PHP to include attachments and information within an email form

This is my PHP code In the HTML form below, I aim to retrieve data from the name, email, phone number fields, and file attachment. When attempting to get the attached file (without any other information entered) in a live server environment, I'm exp ...

Instructions on utilizing clean-css with Node.js to process incoming requests

I need help finding a way to pipe request output into clean-css for minification and then return it as a response. The application I am working on is using restify framework. Here is an example of what I'm trying to accomplish: var url = "http://www ...

Automated logout feature will be enabled if no user interaction is detected, prompting a notification dialog box

Here is my working script that I found on this site. After a period of idle time, an alert message will pop up and direct the user to a specific page. However, instead of just the alert message, I would like to implement a dialog box where the user can ch ...

How can I make a div extend beyond the boundaries of a bootstrap card?

Working with bootstrap version 4 and devexpress. The dropdown section you see is a creation by devexpress. https://i.sstatic.net/8vdj6.png ...

Joomla, Enhancement for iFrame Sizing

A close associate who runs his own construction business has asked me to create a website for him using Joomla. I have successfully implemented most of the features he wanted, but now I need some assistance. He wants to showcase references written about hi ...

Header, footer, and sidebars are all locked in place, while the central content area is designed for

Using this Demo Template as a starting point, I am looking to create a new layout: However, I am encountering the following challenges: The two sidebars are not properly contained within the scrollable content div. The content div does not have a fixed ...