determine the quantity of grid items in place without shifting the element

Is there a way to use CSS grid on a specific container without including one direct descendant as a grid-item? I want to achieve this without changing the structure of my HTML.

The h2 element should not be included as a grid-item.

        <article id="main-diagram"> //CSS grid
        <h2>Ingescheven ouders</h2> // this is the descendant
        <ul id="diagram-times">
            <li>18:00</li>
            <li>19:00</li>
            <li>20:00</li>
            <li>21:00</li>
        </ul>
        <section class="main-diagram-1">
            <p>30%</p>
        </section>
        <section class="main-diagram-2">
            <p>40%</p>
        </section>
        <section class="main-diagram-3">
            <p>50%</p>
        </section>
        <section class="main-diagram-4">
            <p>60%</p>
        </section>
        <ul id="diagram-places">
            <li>12/30</li>
            <li>14/32</li>
            <li>10/20</li>
            <li>32/33</li>
        </ul>
    </article>

Thank you!

Note: currently, there is no CSS applied yet.

Answer №1

Utilize the css attribute grid-template-areas: to define which elements should be displayed and their respective positions.

Here is an example using your provided code:

#diagram-times {grid-area: top-left}
.main-diagram-1 {grid-area: top-right;}
.main-diagram-2 {grid-area: bottom-left;}
.main-diagram-3 {grid-area: bottom-right;}

.container {
  display: grid;
  grid-template-columns: 100px 100px;
  grid-template-rows: auto;
  grid-template-areas: 
  "top-left top-right"
  "bottom-left bottom-right"
}

Check out this amazing guide on grids!

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

Dynamic SVG circles with timer and progress animation

Is there a way to modify the following: var el = document.getElementById('graph'); // get canvas var options = { percent: el.getAttribute('data-percent') || 25, size: el.getAttribute('data-size') || 220, lineW ...

Tips for effectively utilizing the count() function within selenium's xpath feature?

By utilizing the count() function within XPath, we can extract the total count of matching nodes instead of using findElements() and size() methods. Do you know if the count function in XPath returns an integer value? For example, Let's say my xpath ...

What is the best way to access ng model values globally throughout my application?

I am currently working with two modules: the View Items Module and the Add Items Module. Within my project, I have files named app.view.component.ts, app.add.component.cs. How can I utilize the [(ng-model)] values globally in this context? This code snip ...

Styling PHP Input Buttons with CSS

I'm facing an issue with styling the button on a working form. Even though I added CSS and declared the button class, it's not applying the styles. The CSS is defined at the top of the HTML file, and the PHP code is embedded within. Both classes ...

How can I align text in the center of a page and on the same line as a list?

Take a look at my website: I've been struggling to center the text on the screen with the social icons floating to the right. Here's the code I have: Code - <div class='social_icons'> <span class="social_ ...

Maintaining the active style of Asp.NET 4.0 Menu control even after the mouse is released

Utilizing a standard asp.net menu in an asp.net 4.0 web application, this setup is for a standard web application and not any version of MVC applications currently available. The issue at hand is relatively straightforward. CSS styles are applied to the d ...

Creating a new tab with the same html template binding in Angular 4

Could a button be created that, when clicked, opens a new browser tab featuring the same component and variables declared previously? <label>Please Enter Your Email Below</label> <input name="userEmail" type="text" class="form-control" re ...

Remove the div of the previous selection in jQuery and add the current selection by appending it, ensuring only one selection per row is allowed when

Here is a code snippet that includes buttons appending selections to the "cart" div upon clicking. The first script ensures only one selection per row when multiple buttons in the same row are clicked. In the second script, selections are appended to the ...

Tips for sending multiple values to the next page using AngularJS

Hey there, I'm new to AngularJS and currently using Onsen UI in my demo application. I have two pages in my app and I'm trying to pass two values to the next page. I managed to pass one value successfully, but when I attempt to send the second on ...

What is the best way to retrieve tags from an HTML document and transfer them to a different file?

My webpage structure is as follows <unit id="2" status="FINISHED" type="pe"> <S producer="Alice_EN">CHAPTER I Down the Rabbit-Hole</S> <MT producer="ALICE_GG">CAPÍTULO I A ...

Unable to get `tr:nth-child` to function properly within an MVC view

I have come across many questions regarding my issue, but none seem to offer a solution that works for me. The problem lies with the styling in the upper section of my view (which I plan to transfer to bootstrap later on). My main objective is to implement ...

Using a background image in CSS for horizontal rules can override other styling rules

Encountered an unusual CSS bug: After using background-image to style hr, none of the subsequent rules or selectors are displaying on the page: hr { border: 0; height: 1px; background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0 ...

Microsoft Edge breaks free: Introducing Dark Mode for iOS

It seems like Microsoft Edge's "Dark Mode" on iOS has a mind of its own. While it works as expected on Chrome, Safari, Firefox (iOS), and Chrome, Safari, Firefox, and Edge (OSX/Windows), I'm encountering some issues specifically with Edge on iOS. ...

Utilizing the tilde symbol (~) within a link that is generated dynamically

I want to dynamically create sub-menu items with links and URLs using JavaScript. However, I'm encountering an issue where the URL doesn't interpret the tilde (~) as the root directory but simply appends it to the current URL. Here's a snip ...

The issue of drop shadows causing links to not work properly in Internet Explorer

I am currently working on a website design that features a fixed menu positioned behind the body. When the menu icon is clicked, some jQuery code shifts the body to the left. To create the effect of the fixed menu being positioned underneath, I have added ...

Refresh HTML table when database is updated

My panel has a user table which is populated using the following snippet of Php code : <html> <body> <div id="order_table"> <table> <thead> <tr> <th>Name</th> < ...

Having difficulty leveraging the full capabilities of the Jquery.load() function

I'm currently facing an issue where the results I want to display to the user are not filtering properly based on their selection. I've been using GET on the same page (users.php?rid=) to process this, but for some reason, it seems to be loading ...

How do I stop the label element from interfering with the corners of my search bar from rounding

Issue I am experiencing an issue with the appearance of my search bar when using a label element. The corners on the left-hand side are not rounded, and the alignment of the search button is off. When I remove the label element, the search bar looks perf ...

Navigate through unordered list to reach the most recent item

Whenever I add an item and it exceeds a certain size, a scroll bar appears. However, the scroll bar does not automatically scroll to display the latest item added. I would like the scroll bar to automatically move to the bottom every time a new item is add ...

Comparing S3 and DynamoDB for Hosting Static Content

My current project involves showcasing Terms and Conditions for Order fulfillment to customers making purchases on my online platform. Considering the fact that T&C is a static element that doesn't change frequently, I am considering storing this ...