Which is better: Bootstrap or CSS Grid for creating 3 columns with equal height and overflowing content?

I am trying to figure out the best way to create a container with three columns of content. I can't decide if using bootstrap or CSS Grid would be most effective.

Instead of having distinctly separate columns, I would like one continuous column that is divided into three sections stacked on top of each other vertically, similar to the example image provided below. This way, the content will flow seamlessly from one section to the next.

The order of the sections should be as follows: 1,2,3 from left to right horizontally and then 1,2,3 from top to bottom vertically.

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

Answer №1

To achieve the desired layout without using JavaScript, CSS columns must be utilized.

.columns {
  columns: 3 auto;
  padding: 10px;
}

.columns,
.item {
  border: 1px solid black;
}

.item {
  margin-bottom: 10px;
}

.item1 {
  background-color: #B8B4AD;
}

.item2 {
  background-color: #D9DFE5;
}

.item3 {
  background-color: #FFB83E;
}

.item4 {
  background-color: #E86807;
}
<div class="columns">
  <div class="item item1">Lorem ipsum dolor sit amet, consectetur adipiscing elit... (content continues) </div>
  <div class="item item2">Nulla posuere, mi et ultrices volutpat, arcu mi feugiat velit... (content continues)</div>
  <div class="item item3">Donec ut justo sapien. Curabitur iaculis dolor et felis congue... (content continues)</div>
  <div class="item item4">Vestibulum mi ligula, auctor at suscipit sed, dapibus in purus... (content continues)</div>
</div>

With CSS Grid, achieving a similar layout is possible:

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(8, 1fr);
  grid-gap: 10px;
  height: 100vh;
  padding: 10px;
}

.grid,
.item {
  border: 2px solid black;
}

.item1 {
  grid-row: 1 /3;
  grid-column: 1;
}

.item2 {
  grid-row: 3/9;
  grid-column: 1;
}

.item3 {
  grid-row: 1/5;
  grid-column: 2;
}

.item4 {
  grid-row: 5/9;
  grid-column: 2;
}

.item5 {
  grid-row: 1/4;
  grid-column: 3;
}

.item6 {
  grid-row: 4/9;
  grid-column: 3;
}
<div class="grid">
  <div class="item item1">1</div>
  <div class="item item2">2</div>
  <div class="item item3">3</div>
  <div class="item item4">4</div>
  <div class="item item5">5</div>
  <div class="item item6">6</div>
</div>

It's important to note that content won't seamlessly flow across grid columns.

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 causes the styling to break in my CSS media query implementation?

Currently, I am working on making my sidebar fluid so that it adjusts with the browser window size. Everything seems to be going smoothly, except for one issue – when I add a media query to make it responsive, my CSS styling breaks. However, if I remove ...

My customized portfolio incorporates Bootstrap 4 and integrates a modal for collecting feedback. I am looking for a way to gather visitor feedback directly into a Google Sheet without relying on Google Forms

click here to view the image I am seeking feedback on my bootstrap modal from visitors. This portfolio is hosted in HTML and I am looking for a way to gather feedback without using a database, possibly through Google Sheets. ...

The shopping cart is unable to display the name property as it is undefined

I'm currently working on creating a basic shopping cart using JavaScript. $('.addToCart').click(function(event) { event.preventDefault(); var name = $(this).data('name'); var price = Number($(this).data('price')); ...

How can I maintain the

I have created a menu with left and right borders to separate each item. When I hover over the menu, the background color changes to a lighter shade, which is the desired effect. However, the hover effect covers up the left border. How can I prevent the bo ...

Troubleshooting: Android compatibility issues with dynamic source for HTML 5 video

My HTML5 video with dynamic source loaded using JavaScript is functioning properly in a web browser but encountering issues within an Android PhoneGap build application. Take a look at the code snippet below: JavaScript code: $('#video_player' ...

Ways to position <label> and text next to each other in HTML

I have a query about aligning a label and text side by side horizontally. How can I adjust their alignment to center the text within the label rather than at the bottom of it? Below is my current HTML code: <div> <label class="switchnmn"> ...

CSS: concealing certain portions of an element's content

I don't have control over the following markup: <p class="filename"> <img src="http://domain.com/uploads/image_gallery/_thumbs/Chrysanthemum.jpg" alt="Chrysanthemum.jpg"> <br> Chrysanthemum.jpg </p> Is it possible ...

What could be causing my function to execute thrice?

I cannot seem to figure out why my tag cloud is causing the required function to run multiple times instead of just once when I click on a tag. This issue persists whether using jQuery or plain JavaScript. What am I missing? The code I have is very simple, ...

Put the SVG at the lower right corner of the image using Bootstrap

I'm currently attempting to insert an SVG into the lower right corner of an image within a bootstrap card. I experimented with a solution similar to this one: picture on the bottom right cornor of image, but when I apply CSS styles for the icon, my SV ...

Angular's browser animation feature allows for smooth slide-up animations from the bottom

I have been experimenting with creating a simple animation, and it's working, but in the opposite direction of what I intended. I want the div to open from bottom to top and close from top to bottom. Here is my animation code in Angular: animations: ...

I am attempting to draw a correlation between two numerical variables

I'm struggling to compare two scores in my game. When they match, I want it to display "You won", but I can't get it to work. I've attempted using the parseInt method and .val method, but no luck so far. var numberFour = Math.floor(Math.ra ...

Matching Javascript Variables to CSS Styles

I am currently developing a small HTML page and I am utilizing JavaScript to retrieve the screen dimensions. However, I am facing an issue with passing this variable to a CSS style as shown below. How can I achieve this successfully? Additionally, I have ...

Hiding a related field using a designated delimiter can be achieved with JavaScript

I am looking to create a function that hides the corresponding textarea field of a dropdown. This functionality will be utilized in multiple instances, hence the need for it to be within a function. <div id="formElement1" class="field"> <labe ...

Updating the default date in Bootstrap datetimepicker can be done through the use of a Bootstrap modal. Here

How can the default date value be updated when using datetimepicker within a bootstrap modal and displaying both datepicker and time picker inline? The issue is that the datetimepicker value updates on the first click after refreshing, but on the second cl ...

Using JS/PHP to send a POST request to a PHP script for querying a database

Trying to gather user input and then pass it to another PHP script for utilizing in a MariaDB query. Index.php: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="robots" content=&q ...

show data rows in the form of boxes

let employees=[{app:"new",comment:"sjkk",date:"02/10/2018"},{app:"new",comment:"sjkk",date:"02/10/2018"},{app:"new",comment:"sjkk",date:"02/10/2018"}]; <table class="table" style="width:100%;"> <thead style="background-color:#FDDDD2"> <tr ...

JavaScript code to modify a table row

I have a dynamic table that increases with Firebase data, and I am trying to incorporate a delete and edit button on each row. While the remove button is working fine, I am facing issues with implementing the edit functionality. Although I came across some ...

Selecting Specific File in Directory Using HTML File Input

Can you customize an HTML file input to choose a particular file from a directory or drive? By clicking on the file input button, the user opens the file selector and selects a folder or external drive. With jQuery, it is then possible to specify a specif ...

Enhance your viewing experience by magnifying a specific element, all while maintaining full control to navigate

Is it possible to create a zoom effect on a webpage that focuses on one specific element while still allowing for navigation and scrolling? I have searched online for plugins like Fancybox and Zoomooz, but none of them offer the functionality I need. I sp ...

The image fails to reach full width and does not expand correctly when I zoom out

At the bottom of my website, I have a bar for displaying certain content. However, I am facing an issue where the bar is not extending to cover the entire screen width despite having code in place to do so. The HTML code is quite basic: <div class="bo ...