Tips for designing a flexible structure with 2 columns, each containing an additional 2 columns within

Is it possible to create a 4-column responsive layout?


| column left | column right | column left| column right|

I would like to achieve a single row layout on larger devices as shown below

| column left | column right | column left| column right|

and on medium & small devices, it should look like this:

| column left | column right |

| column left | column right |

Answer №1

If you want to utilize the bootstrap grid system, here's how you can do it:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">col 1</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 2</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 3</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 4</div>
</div>

Give it a try by clicking on "Run code snippet." You'll be able to see the demo for small screens. Then, click on "Full page" to view it on larger screens.

Bootstrap's grid system is designed for four screen sizes:

  1. lg for laptops and desktops - screens equal to or greater than 1200px wide
  2. md for small laptops - screens equal to or greater than 992px wide
  3. sm for tablets - screens equal to or greater than 768px wide
  4. xs for phones - screens less than 768px wide

The screen is divided into 12 parts, so the number after each screen size specifies how many parts the div should cover.

For example, in the code provided above, the divs will cover 3 parts on large screens and 6 parts on small screens.

For more details on the bootstrap grid system, check out this resource.

Answer №2

If you want to improve your webpage layout, consider using the bootstrap grid system. This system utilizes containers, rows, and columns to organize and align content in a flexible and responsive manner. Take a closer look at the example below to understand how the grid functions:

<div class="container">
  <div class="row">
    <div class="col-lg-3 col-md-6 col-sm-6"">
      This is one of three columns
    </div>
    <div class="col-lg-3 col-md-6 col-sm-6"">
      This is one of three columns
    </div>
    <div class="col-lg-3 col-md-6 col-sm-6"">
      This is one of three columns
    </div>
    <div class="col-lg-3 col-md-6 col-sm-6"">
      This is one of four columns
    </div>
  </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

Issue with opening mobile app from deep link in HTML email

My HTML form contains a deeplink that is submitted through the SendGrid API on nodeJS. After sending the email, users can view it but are unable to click on the deeplink. <!DOCTYPE html> <html> <head> ...

Is it possible to use PHP to add a prefix to every selector in a snippet of CSS code?

Suppose I have a variable named $css that holds some CSS code. My goal is to prepend a specific text to each selector. For instance, consider the following CSS code: #hello, .class{width:1px;height:1px;background-color:#AAA;} div{font-size:1px} input, a, ...

What is the best way to enhance specific sections of Django content by incorporating <span> tags, while maintaining the original paragraph text format?

I am currently in the process of trying to showcase a paragraph of text (content) from django. However, my aim is to incorporate <span class="modify"> into particular words that match pre-defined words located within a referenceList within the paragr ...

Can the floating side of a div be switched after resizing?

Let's say I have two divs set up in the following configuration: |------------------------------| | div1 ------------------ div2 | |------------------------------| .div1{ float:left; } .div2{ float:right; } From my understanding, they w ...

The video attribute in HTML is malfunctioning on the react webpage

Currently working on setting up a basic portfolio layout with a video playing in the background on loop. However, despite making some adjustments and modifications, the video is not showing up as expected. Any insights or suggestions on what might be causi ...

Displaying inline causes the block elements to be removed from the

After two months of learning HTML and CSS, I still feel like a beginner. I'm attempting to create a header navigation bar, but whenever I apply the display: inline property, everything vanishes. I know this issue is probably basic, but any advice woul ...

Develop a straightforward static webpage and set it up by installing and launching it using NPM

I am attempting to craft a straightforward HTML page that incorporates CSS/JS and utilizes npm. The objective is to construct a basic page that can be accessed by simply using "npm install" and "npm start". As an example, I will design a page with HTML, ...

specialized html elements within data-ng-options

I have a code snippet where I am populating select options from a controller using data-ng-options. However, I would also like to include an icon with each option. For example, I want to append <span class="fa fa-plus"></span> at the end of e ...

Is there a way to make the header reach the full width of the page?

Is there a way to make my header extend across the entire page? I attempted using margin-left and right, but it didn't yield the desired outcome. Header.css .header{ background: green; height: 70px; width: 100%; display: flex; ju ...

Why are two vertical scrolls appearing on the screen simultaneously?

I utilized this method to hide the body scrollbar initially and then display it upon clicking a link: $('body').css('overflow', 'hidden'); $('#site').click(function(e) { $('#wrapper').remove(); $(& ...

Show the saved email message text on an HTML webpage

Is there a way to show the email content stored in a HTML page? $.ajax({ type: "POST", url: "./mailBody.php", dataType: 'json', success: function (data) { $.each(data, function(index, element) { $('.mail ...

I'm having trouble getting the font to display properly on Safari (mac) similar to how it appears on

Recently, I completed a website for a client at . The owner requested the footer text to be styled similarly to the footer text on . However, upon review, it seems that the font in the lists on desiringgod appears thinner compared to the site I built. Thi ...

Modify the NAME attribute when clicked using Jquery

I am attempting to modify the NAME attribute of a DIV with the text from a textbox using jQuery. Take a look at my code snippet: http://jsfiddle.net/e6kCH/ Can anyone help me troubleshoot this issue? ...

How to align content within a FormControlLabel using Material UI

My goal is to line up the label and radio button inside a FormControlLabel component so that the label occupies the same width regardless of its content. The current appearance can be seen below: https://i.stack.imgur.com/GhXed.png Below is the code I am ...

Is it possible to access the operating system's native emoji picker directly from a website?

While there are numerous javascript plugins and libraries available for allowing users to select emojis for text inputs, both Windows and Mac operating systems already have their own native emoji pickers accessible via ⊞ Win. or CTRL⌘Space. Is there a ...

What steps can I take to address the div issue in my React application?

After implementing Browser Router, I am encountering whitespace on the left and right side of the navbar. How can I resolve this issue? Below is the code snippet: <div className="container my-3"> <BrowserRouter> ...

Web page saving fails to preserve images!

Currently working on a PHP-based website that is utilizing the Zend framework and hosted on an Apache server. The folder structure within my www directory looks like this: +www | |_+css | | | |_images | |_js | |_images The issue I'm ...

When the 'Show More' button is clicked, one Div will smoothly slide over another Div

I've been struggling for hours to find a way to make one DIV slide over another DIV below it instead of pushing it down. The setup is quite straightforward. I have a script that reveals more text when the 'Show More' button is clicked. Desp ...

What is the best way to ensure the checkbox functions correctly in this specific situation?

I am utilizing PHP, Smarty, and jQuery in the development of my website. Currently, I am working on implementing checkboxes within a Smarty template. Below is a snippet of my Smarty code related to checkboxes: <table cellpadding="5" cellspacing="0" bor ...

Encountering an ElementClickInterceptedException while trying to click the button on the following website: https://health.usnews.com/doctors

I am currently in the process of extracting href data from doctors' profiles on the website . To achieve this, my code employs Selenium to create a web server that accesses the website and retrieves the URLs, handling the heavy lifting for web scrapin ...