What are the steps to design a schedule with CSS Grid?

I am attempting to replicate the image shown below using CSS grid, but I am having trouble figuring out how to create elements that span multiple columns.

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

Here is the current code I have:

    <div class="Grid">
        <div class="Grid-Column">
            <div class="column">1</div>
            <div class="column">2</div>
            <div class="column">3</div>
            <div class="column">4</div>
            <div class="column">5</div>
            <div class="column">6</div>
        </div>;

        <div class="Grid-Rows">
            <div class="row">Monday</div>
            <div class="row">Tuesday</div>
            <div class="row">Wednesday</div>
            <div class="row">Thursday</div>
            <div class="Row">Friday</div>
        </div>;

        <div class="Grid-Element">
            <div>A</div>
            <div>B</div>
            <div>C</div>
            <div>E</div>
            <div>F</div>
        </div>;
    </div>

Answer №1

I'm not certain if this approach is the most effective, but give it a try:

.Container {
  width: 700px;
  height: 500px;
  border: 2px solid red;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.Monday {
  grid-row-start: 2;
  grid-row-end: 3;
}

.Tuesday {
  grid-row-start: 3;
  grid-row-end: 4;
}

.Wednesday {
  grid-row-start: 4;
  grid-row-end: 5;
}

.Thursday {
  grid-row-start: 5;
  grid-row-end: 6;
}

.Friday {
  grid-row-start: 6;
  grid-row-end: 7;
}

.a {
  grid-row-start: 3;
  grid-row-end: 4;
  grid-column-start: 3;
  grid-column-end: 5;
}

.b {
  grid-row-start: 3;
  grid-row-end: 4;
  grid-column-start: 7;
  grid-column-end: 8;
}

.c {
  grid-row-start: 4;
  grid-row-end: 5;
  grid-column-start: 4;
  grid-column-end: 5;
}

.d {
  grid-row-start: 4;
  grid-row-end: 5;
  grid-column-start: 5;
  grid-column-end: 6;
}

.e {
  grid-row-start: 5;
  grid-row-end: 6;
  grid-column-start: 2;
  grid-column-end: 3;
}

.f {
  grid-row-start: 5;
  grid-row-end: 6;
  grid-column-start: 5;
  grid-column-end: 7;
}
<div class="Container">
  <div></div>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>

  <div class="Monday">Monday</div>
  <div class="Tuesday">Tuesday</div>
  <div class="Wednesday">Wednesday</div>
  <div class="Thursday">Thursday</div>
  <div class="Friday"></div>

  <div class="a">A</div>
  <div class="b">B</div>
  <div class="c">C</div>
  <div class="d">D</div>
  <div class="e">E</div>
  <div class="f">F</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

Designing an HTML and CSS footer navigation bar

Can you help me create a footer menu using HTML and CSS? Check out this image for reference Any tips on how to style it with cascading style sheets? <footer> <ul> <li><a href="">Home</a> </li> <li> ...

Looking to incorporate Bootstrap Icons within Semantic UI?

I'm in need of assistance. My current project involves using Semantic UI, but there's a requirement to incorporate Bootstrap icons from . However, I'm facing difficulty copying the svg information directly into the code for the sake of reada ...

There seems to be an error with JVectorMap: the <g> attribute transform is expecting a number but is instead receiving "scale(NaN) translate(N..."

Hey there! I'm currently working on creating a form with a map to select the country of birth using JVectorMap. However, when checking the Google Chrome developer console, I encountered the following error message: jquery-jvectormap-2.0.5.min.js:1 Err ...

Exploring MVC 5's View and Controller Components

In my GetCourseList.cshtml file (view), I have the following code that displays fetched information from the database: @model IEnumerable<WebApplication8.Models.Courses> @{ Layout = null; } <!DOCTYPE html> <html> <head> ...

I'm having a hard time understanding how to use array_filter()

<html> <style> h1 { text-align: center; } div { text-align: center; border: 1px solid; padding: 20px; width: 520px; margin: 0 auto; } table{ text-align: center; border: 1px solid; padding: 20px; width: 5 ...

Show the updated count retrieved from a specific record in a database table using Ajax technology

I am looking to retrieve the latest ID from a database table and then increase it by 1. I want to display this incremented value in either an Input or Label element of HTML, instead of using tables as most tutorials do. Below is a snippet of my code: inde ...

Ways to center text vertically alongside an image

<ion-view view-title="个人信息"> <ion-content> <style> .user-details { display: flex; align-items: center; justify-content: space-between; height: 80px; } .us ...

How to hide offcanvas navigation bar with one click in Bootstrap 5

There was an issue with a Bootstrap 5 project where the offcanvas menu would remain open after clicking on an anchor link. Is there a way to automatically close the offcanvas menu after clicking on an anchor link? <nav class="navbar fixed-top py ...

The navigation bar vanishes as soon as I click the Modal button

I am experiencing an issue where the Navbar disappears when I open a modal while using Bootstrap. Navbar before opening Modal https://i.stack.imgur.com/Oo9qb.png Navbar after opening Modal https://i.stack.imgur.com/dlK1V.png <script src="https:// ...

What is the best way to ensure all class=service-block elements have the same height?

While working on customizing a Hugo theme, I'm struggling to find information on how to set text boxes to a consistent height. Currently, the height of the boxes varies based on the amount of text they contain. This is how the text boxes are currentl ...

Utilizing Angularjs for dynamic data binding in HTML attributes and style declarations

Can someone help me figure out how to use an AngularJS model as the value for an HTML attribute? For example: <div ng-controller="deviceWidth" width={{width}}> </div> Additionally, how can I achieve this within <style> markup? Where ...

Using a CSS pseudo-element within a PHP script does not produce the desired results

One challenge I'm facing is that I had to include the <?php ?> tag in my PHP code in order to add styles using pseudo element span:before with content: 'text' which contains translations for multiple languages. The <meta charset="u ...

Steps on how to trigger an onmouseover event for entire blocks of text:

I'm currently in search of an onmouseover code that seems to be elusive on the vast internet. A CSS box format has been successfully created: .box { float: left; width: 740px; height: 300px; margin-left: 10px; margin-top: 10px; padding: 5px; border: ...

The wrapAll() method can be used to wrap list items within two columns

I am looking to group multiple li elements within two div containers by using jQuery's wrapAll method. The challenge lies in the fact that these items are rendered within a single <ul> element via a CMS. Here is the current setup: <ul> ...

Exclude a specific link from a JQuery function

Check out this unique single page site that utilizes a waypoint script for navigation and highlighting nav items - The functionality works seamlessly, however, we are facing an issue where we need to modify a link to redirect to an external website. Unfor ...

Changing the selection of a ComboBox in WebDriver using the "webkit-user-select" attribute

I attempted to alter the selection of a combobox with a "webkit-user-select" type in various ways, but unfortunately, none of my attempts were successful. 1) import org.openqa.selenium.support.ui.Select; Select select = new Select(driver.findElement(By. ...

Issue arises when attempting to submit multiple form fields with identical 'name' attributes, preventing the fields from being posted

Currently, I am facing a challenge with old HTML/JavaScript code. Some parts I have control over, while others are generated from an external source that I cannot manage. There is a form created dynamically with hidden fields. The form is produced using a ...

Prevent Fixed Gridview Header from being affected by browser Scroll-bar using JQuery

Is there a way to make the fixed header responsive to only one scroll bar in JQuery? Specifically, is it possible to have it respond solely to the div's scroll bar and not the browser's scroll bar? I attempted to remove the browser's scroll ...

The value returned by $(this).next() is undefined

I'm struggling to implement jQuery functionality to toggle the display of a div, but I am encountering an issue where my jQuery code is unable to select it. Every time I try, it returns undefined. Can anyone provide assistance? $(document).on(&apos ...

Utilize PHP to Extract ID3 Tags from MP3 Files and Embed Them into HTML

While conducting some research, I stumbled upon a helpful resource: ID3 Functions. This guide is all about PHP and how to utilize ID3 functions in web development. I'm interested in learning more about how to incorporate this into a website so that: ...