Guide on exchanging the position of items in the second row of a grid

Could someone assist me in achieving a layout like the one shown in this grid? The desired result can be seen in this link: https://ibb.co/XbW025V. Here is my code for reference: https://jsfiddle.net/o0zjuyqb/1/

<div class="container">
     <div class="parent">
       <div class="div1"></div>
       <div class="div2"></div>
       <div class="div3"></div>
       <div class="div4"></div>
       <div class="div5"></div>
       <div class="div6"></div>
      </div>
    </div>

Answer №1

To achieve this effect, simply utilize the CSS property grid-column: span 2;

.grid-layout {
  display: grid;
  grid-auto-flow: dense;
  grid-template-columns: 250px 290px 290px 250px;
  grid-template-rows: repeat(2, 280px);
  gap: 40px;
}

.grid-layout div {
  background-color: grey;
}

.grid-layout div.wide {
  grid-column: span 2;
  background-color: green;
}
<div class="grid-layout">
  <div class="wide"></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div class="wide"></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

The Alignment of My Footer

My goal is to center the footer when it reaches the lg break point, so that the three columns appear as one column in 3 rows, positioned at the center of the page. However, upon visiting the codepen link below, you'll notice that the second column is ...

Issue with grid element not properly scaling using the transform:scale property

I have encountered an issue where a simple grid, with the gaps set to 0, displays a small line when I apply the transform:scale(1.5) css property. I am unsure if this is a bug or if I am doing something incorrectly. Interestingly, the result in Firefox dif ...

Personalized HTML Selection Arrow Graphic

I am seeking a solution to hide the default arrow of the HTML select list and instead add a custom image (arrow) to the list. https://i.sstatic.net/HF7vO.png .form-inline select { margin: 10px 35px 15px 0px; background-color: #fff ...

Aligning Header and Search Icon in Perfect Harmony with the Body

I've been struggling with alignment issues on my Tumblr blog. Specifically, I'm trying to align a header and a search icon. You can find my site here. Here is the mockup I am aiming for: However, if you visit my site, you'll notice that ...

Is there a method to track the progress of webpage loading?

I am working on a website built with static HTML pages. My goal is to implement a full-screen loading status complete with a progress bar that indicates the page's load progress, including all images and external assets. Once the page has fully loaded ...

A Complication Arises with Browser Functionality When Embedding an Iframe within

I am experiencing a peculiar problem while embedding an iframe with a specific src inside an absolutely positioned div. Here's the basic structure of the webpage: .container { position: relative; overflow: hidden; width: 100%; heigh ...

Attempting to achieve the desired grid layout with Bootstrap 4

Need help achieving this Grid layout Hello, I am new to Bootstrap 4 and I am trying to achieve the layout shown in the image linked above. Here is what I have tried so far... <div class="container"> <div class="row"> <div class="col-md-4 ...

Leveraging jQuery for vertical alignment of an image

I am trying to vertically center an image with the class .personal within a container with the class .personal-row (located inside .row-main) on page load and when resizing. Initially, I attempted using vertical-align: middle;, but that did not yield the d ...

jQuery text slideshow not working properly when a <br> tag is present

I'm looking to develop a basic text slideshow that smoothly transitions between phrases and loops continuously. However, I've run into an issue where the slideshow malfunctions when I add a line break in the text. It only seems to work properly w ...

Styling a floating options menu in React Select

Hey there, I've been tackling the react-select implementation and ran into a css issue. When react-select is opened within a container with overflow:auto (which I can't modify since it's not part of my app), the options are displaying like ...

Is it possible to maintain the width of an element even when its height is set to 0px?

Let me provide a detailed explanation of my issue below, but the question remains the same: Is there a way to make an element hidden or invisible with a height of 0px or slightly more than 0px while maintaining its width for functionality in Safari? Here ...

Prevented a frame from "https://googleads.g.doubleclick.net" from accessing another frame

After placing ads on my website, they are displaying properly. However, I am receiving an error repeatedly in the console when the page loads: A frame from origin "" is being blocked from accessing a frame with origin "". The requesting frame has an "ht ...

Troubleshooting CSS issues in HTML pages

I created an HTML file but the CSS properties are not displaying correctly in the browser. I'm not sure where I made a mistake. Instead of using a separate CSS file, I have included it directly in the HTML file. <!DOCTYPE html> <html> &l ...

if the checkbox is selected, navigate to the displayed section

In my scenario, I have a total of 5 checkboxes and corresponding to each checkbox, there are 5 div elements. The functionality that I need is that when a checkbox is checked, the associated div should be displayed; otherwise, it should be hidden. The check ...

What could be causing the issue with the jquery height function not functioning properly

I am working on a website where the menu bar and footer need to be 50px in height as shown in the image. In between the nav and footer, there is a content div that should occupy the remaining space. To achieve this, I plan to use Jquery to calculate the do ...

Choosing siblings of a particular element that meet certain criteria

I am faced with the following situation: <table> <tr class="header"> <tr class="data1"> <tr class="data2"> <tr class="data3"> <tr class="header"> <tr class="data1"> <tr class="data2"> </tabl ...

Is there a way in CSS/3 to dynamically adjust the height based on the width?

Is there a way in CSS/3 to maintain the shape ratio of a div while keeping it responsive? Let's say the container is 100px wide. For example: width: 100%; height: 100%-of-width; Result: The div is 100px wide and 100px high. Another example: ...

How can I create a timed slideshow of images?

Is there a way to make a series of images slide automatically after closing or stopping a video? To see the specific website in question, click here: Upon visiting the site, a video pops up. How can I program the image slides to transition every 7 secon ...

Is the use of div:after content really affecting the width? I am having trouble getting my transition to work

Here is a simple code snippet that represents my actual code: #myDiv { background: black; color:white; float:left; min-width:45px; max-width:450px; -webkit-transition: all 1s ease-in-out; transition: all 1s ease-in-out; } #myDiv:hover:after { width ...

Issue with the Ajax auto-complete feature in Internet Explorer

I am facing an issue with my "ajax suggestion list" getting hidden behind the "select menu" located right below the text box that triggers the ajax function. This problem only occurs in IE 6.0, while it works fine in other browsers. I have already disabled ...