Issues with CSS Grid template areas functionality are causing unexpected behavior

I'm having trouble replicating a layout using grid-template areas, and for some reason, it's not displaying correctly. I've checked my code multiple times, and it seems correct to me. Can anyone provide guidance on how to successfully recreate this layout using grid-template-areas?

.a {
  background: red;
  grid-area: a;
}

.b {
  background: green;
  grid-area: b;
}

.c {
  background: aqua;
  grid-area: c;
}

.d {
  background: darkblue;
  grid-area: d;
}

.e {
  background: purple;
  grid-area: e;
}

.f {
  background: orange;
  grid-area: f;
}

.grid-container {
  display: grid;
  margin: auto;
  grid-gap: 8px;
  grid-template-areas: "a a a a" "b c c c" "b c c c" "b c c c" "b c c c" ". . d d" "e e e e" "e e e e" "e e e e" "f f f f";
}
<div class="grid-container">
  <div class="a"></div>
  <div class="b"></div>
  <div class="c"></div>
  <div class="d"></div>
  <div class="e"></div>
  <div class="f"></div>
</div>

Codepen: https://codepen.io/mauro-scheltens/pen/vYrKdwq

The layout I'm attempting to replicate

https://i.sstatic.net/igKKz.png

Answer ā„–1

To create separate rectangles for each element, you will need to add as many div elements in your HTML code as there are elements desired. However, if you want the rectangles to expand within a grid layout, you can achieve this by adding the grid-template-rows property to your CSS like so:

.grid-container {
  display: grid;
  margin: auto;
  grid-gap: 8px;
  grid-template-areas: "a a a a" "b c c c" "b c c c" "b c c c" "b c c c" ". . d d" "e e e e" "e e e e" "e e e e" "f f f f";
  grid-template-rows: repeat(11, 100px);
}

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

Utilizing jQuery to create a fade-in effect for li elements on hover

Working on a fresh WordPress theme, aiming to bring some lively animations to the pages compared to the previous interface. Looking to incorporate an effect like a fade-in effect to my li:hover element. Any ideas on how to achieve this? Sample CSS: /*Vi ...

Tips for switching back and forth between two classes using jQuery?

I'm having some trouble with the toggleClass function. It doesn't seem to be working correctly for me. The image should toggle between displaying and hiding, but it only changes to hide, not back again. You can view my example here, along with t ...

What is the best way to increase the spacing between images in a navbar?

Having trouble aligning images in navbar with bootstrap. Tried various solutions without success. Here is my code snippet and image of my current page: <body> <header id="header" class="fixed-top"> <nav class=" ...

Is it possible to sanitize user input without relying on !important?

Utilizing wp_editor, I have implemented a front-end form on my WordPress website for users to post without accessing the admin section. Although it is functional, there is a concern that users may copy and paste content with inline styles that could disrup ...

Improving loading time for pages requiring jQuery to render

Currently, I am utilizing the Google PageSpeed service to enhance the loading time of my website. It is hosted on GAE/P, but that detail may not be crucial in this context. There are several resources my page relies on: Bootstrap (css and js) jQuery (js ...

Menu remains open even after clicking the nav button again

I've been searching extensively, but haven't found a straightforward solution to the issue. When I click the button, it opens but doesn't close again. Any suggestions on what might be missing? Thanks in advance. <nav class="navbar navbar ...

What is the method for including footer content on a site that only has a masthead?

Is there a way to incorporate footer-type text with copyright disclaimer into a masthead-only website? I keep trying to add a footer, but it ends up getting stacked outside the masthead, causing the screen to become scrollable. My goal is to include the co ...

Tips for modifying the color of the input field in Ionic 5 upon receiving focus

Is there a way to change the color of an input field when it's focused? Currently, it turns grey only when focused by a function and remains so until typing or clicking on the field. export function autofocus() { let blanks = document.querySelecto ...

jQuery slider - display unlimited images

Currently, I am encountering issues with a Flickity carousel of images. When an image/slide is clicked, a modal window opens to display a zoomed-in version of the image. The problem arises when there are more or fewer than 3 images in the slider ā€” my cod ...

Unable to combine two items within the same row in the cell

My current structure looks like this: <td class="sorting_1" tabindex="0"> <div class="form-check" data-user-id="1"> <label class="form-check-label"> <input class="form-check-input" type="checkbox" value=""> ...

How to apply CSS classes to dynamically injected HTML in Angular 7

One of the challenges I'm currently facing is how to assign a CSS class based on a calculation in my component. Here's a snippet from my component class: @Component({ selector: 'app-render-json', template: `<div [innerHtml ...

What is the process for updating tabs and their content in React?

Here is where the error occurs in my JavaScript code. I have successfully implemented it in HTML, CSS, and simple JavaScript, but encountered issues when trying to do so in React. My goal is to switch tabs and their corresponding data/content: ...

Break down and simplify the code into individual components

<input type='button' class="myButton" onclick="document.body.style.cssText+=';background-image: url(img01.jpg);background-repeat: no-repeat; -moz-background-size: cover; -o-background-size: cover; background-size: cover;';" value="S ...

Is there a way to align a div to the center of the BODY element instead of its parent in

I have a sticky navigation bar with the tab "categories" that reveals the dropdown menu "categoriesDropdown" when hovered over. I want the dropdown menu to span the width of the screen and be centered on it. I also need the dropdown menu to stick to ...

Smooth Transition When Page is Fully Loaded

Is it possible to apply a saturation effect with ease-out to my logo once the page is loaded, or does it only work with "hover"? Here is the code I'm using: /* CSS*/ #logo { -moz-transition: all 7s ease-out; -o-transition: all ...

Overrule the child element selector using a class identifier

I'm facing an issue where the descendant selector is overriding my .red_p class. Is there a way to prevent this from happening without having to assign a class to each p element individually? HTML: <html> <head> <style> ...

Utilize JQuery addClass to implement CSS animations that run only once by setting a boolean variable to true or

I am working on a CSS animation that I want to trigger when the page is visible in the browser. To achieve this, I am using a function that determines the position (referred to as "posish"). The animation should run once when the page comes into view or wh ...

Struggling to align a button in the middle of an HTML form using flexbox - see code snippet below

Hey everyone, Iā€™m having trouble with centering my button within the flexbox container with the class "hero". Any thoughts on why this might be happening? The button appears below the email form but is aligned to the left of it (starting at the same pos ...

What is the best way to overlay an image on two divs/containers simultaneously?

I've been tasked with creating a web mockup featuring a transparent PNG image overlaying two divs in multiple rotations. I've used Bootstrap 4.1 to structure the site, utilizing containers, rows, and cols. <section class="one"> <!-- ...

Webpage refreshing when resizing browser

Hey there, I'm facing an issue where my HTML website restarts whenever the browser size changes. Can someone please help me fix this? You can check out my website here I have uploaded my code files here: Code Files Link ...