Struggling with aligning content within a div using CSS grid techniques

I am experimenting with CSS Grid and running into issues with overlaying content. The structure consists of a top-level container defined as a CSS grid (class="container"), followed by a content grid (class="content") that divides into 3 rows (header, label, rows). The header is simply a header, the label contains labels for the rows, and the rows represent the content in a "table"

Here is a visual representation: https://i.sstatic.net/0iYDp.png

Upon resizing the window, I notice a scrollbar on the right side that affects the entire page. I would prefer the scrolling to be limited to the rows section only, not the whole page. https://i.sstatic.net/LnErJ.png

You can view a working example on StackBlitz here: https://stackblitz.com/edit/angular-ivy-ayujp5

Although it seems straightforward, I'm struggling to grasp how height is calculated and where and how overflow properties should be defined.

p {
  font-family: Lato;
}

.container {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  grid-template-rows: 30px 1fr 30px;
  grid-template-areas: '. . .' '. content .' '. . .';
}

.content {
  grid-area: content;
  display: grid;
  grid-template-rows: 50px 30px 1fr;
  grid-template-areas: 'header' 'label' 'rows';
}

.header {
  grid-area: header;
}

.label {
  grid-area: label;
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: repeat(3, 4fr);
  align-items: center;
}

.rows {
  grid-area: rows;
  height: 100%;
}

.row {
  background-color: pink;
  margin: 5px 0px;
  border-width: 1px;
  border-radius: 10px;
  padding: 25px;
  color: black;
}
<div class="container">
  <div class="content">
    <div class="header">Header</div>
    <div class="label">
      <div>Name</div>
      <div>From</div>
      <div>To</div>
    </div>
    <div class="rows">
      <div class="row">
        <div class="label">
          <div>1</div>
          <div>1999/01/01</div>
          <div>1999/12/01</div>
        </div>

      </div>
      <div class="row">
        <div class="label">
          <div>2</div>
          <div>1999/01/01</div>
          <div>1999/12/01</div>
        </div>

      </div>
      <div class="row">
        <div class="label">
          <div>2</div>
          <div>1999/01/01</div>
          <div>1999/12/01</div>
        </div>

      </div>
      <div class="row">
        <div class="label">
          <div>3</div>
          <div>1999/01/01</div>
          <div>1999/12/01</div>
        </div>

      </div>
      <div class="row">
        <div class="label">
          <div>4</div>
          <div>1999/01/01</div>
          <div>1999/12/01</div>
        </div>

      </div>
    </div>

Answer №1

I typically use the following method for calculating height:

.pin-table { height: calc(100vh - 125px); overflow: auto; }
. However, I'm open to hearing any alternate suggestions.

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 sidebar made an unexpected leap from one side to the other, with no memory of ever tampering

I'm feeling a bit overwhelmed because I can't seem to figure this out. My goal is to create a basic page layout with a header, subheader, sidebar, content pane, and footer. Everything was going smoothly until I started writing a function in my J ...

What could be causing my div to not appear when using jquery's show function?

I'm dealing with HTML code that looks like this: <div id="answerTypeSection" style="visibility: hidden"> <div class="row"> <div class="col-md-2">adfadfafasdfasdfas</div> </div> <label class="control-label"&g ...

How to adjust animation timing for various elements during a CSS 3D flip with a delay?

Here is a CSS flip setup that I have been working on in this fiddle: http://jsfiddle.net/6r82fzk6/ The Goal: I am trying to achieve a slower transition for the back element compared to everything else. The idea is to have the child element of the back fac ...

Guide to modify target blank setting in Internet Explorer 8

<a href="brochure.pdf" target="_blank" >Click here to download the brochure as a PDF file</a> Unfortunately, using 'target blank' to open links in a new tab is not supported in Internet Explorer 8. Are there any alternative solutio ...

Shifting the "active" designation within a dropdown menu to correspond with the user's current page

Recently, I decided to explore the Foundation framework. However, my first stumbling block was figuring out how to use the "active" class in a dropdown menu. I am hoping to have the class applied to the page link that is currently being viewed by the user ...

Utilize Node.js and Cheerio to extract data from an HTML table

Having trouble converting an HTML table to JSON. HTML table structure: <div id="content"> <h1>content-information</h1> <table class="testinformation"> <thead> <tr> ...

The issue with the JQuery Cookie Plugin is that it is unable to function properly due to the

Although I know there are many similar questions out there, please bear with me. I am not as proficient in JQuery as I am with HTML/CSS, and this is my first time using cookies. On my website, I have a green banner that should disappear when the user click ...

Discover the secret to extracting a unique style from inspect mode and incorporating it into your CSS design

I'm currently working on my angular project and I've imported the ngx-editor. My goal is to reduce the height of the editor, but I'm facing some challenges. After inspecting the element, I was able to adjust the height successfully within th ...

"Jsoup interprets certain characters in a unique way during parsing

I attempted to parse this HTML file using Jsoup: <html><body>Maître Corbeau, sur un arbre perché</body></html> The line of code I used was: Document document = Jsoup.parse(input, "UTF-8"); However, when I tried to print the do ...

Examples of how to specify a child class in CSS

Presented here is the following structure: <article class="media media--small 48"> <a href="#"> <img src="" class="media__img" alt=""> <i class="s s--plus"></i></a> <div class="media__body"> < ...

Using ChartsJs to visualize input data formatted in the German data format

I am relatively new to working with Charts.js, but I will need it to generate some visually appealing graphs for my website. In the background, I have a Django project running that calculates a specific set of numbers for me. Due to the language setting in ...

Is AngularJS governed by a distinct set of guidelines for ARIA implementation?

I am currently working on updating a website to ensure compliance. The site is predominantly built using AngularJS, which I am still in the process of learning. I encountered an interesting situation where there is a label targeting a div element without a ...

Strange Appearance of Angular Material Slider

I am experiencing some issues with my slider and I'm not exactly sure what's causing them. [] .big-container { display: block; padding-left: 10px; padding-right: 10px; padding-top: 10px; margin-bottom: 10px; } .question { display ...

Create a dropdown menu option that changes based on the number of items that have been

I need a selection option that displays values 1 to 5. Depending on the selected value, it should generate select options equal to the number selected. For example, if I choose 3, then it should generate 3 select options. Is it possible to loop the ajax in ...

How can you set a condition for when no matches are found in a list filter?

I recently came across a fascinating example on W3 Schools that taught me how to implement a search filter. Below, I have customized it for everyone's reference. I am interested in modifying it to only display a list item with the message: No matche ...

What is the process for loading the chosen option JSON object from an array when a button is clicked?

I have a TypeScript file containing JSON objects that can be selected as options from a dropdown list. I am looking for guidance on how to load/instantiate the selected JSON object when the user clicks a button to proceed. Specifically, I would like to le ...

Trouble with z-index | initial div out of four malfunctioning

Currently, I am attempting to practice by replicating the design shown in this image: https://i.sstatic.net/iIA2q.jpg However, I have encountered an issue that has been persisting for some time: https://i.sstatic.net/grABz.png I'm struggling to un ...

How to Style Your ASP.NET Website: Utilizing a Stylesheet with Visual Studio 2010

I am having trouble adding a stylesheet to the master page of my asp.net web form. I want to create an inline navigation menu at the top of the page, but I can't seem to get it working. I have created the stylesheet in the same way I would for an HTML ...

Dynamic Rendering of Object Arrays in Table Columns using JavaScript

In the process of developing an appointment slot selection grid, I have successfully grouped all appointments by dates. However, I am facing challenges in displaying this array of Objects as a clickable grid with columns. The current output can be viewed h ...

Difference among rows

I am currently working on a table design with 2 rows that have different colors. There seems to be some space between the two rows and I am looking for a way to eliminate that gap. Can anyone provide me with a solution? https://i.stack.imgur.com/8N8Rw.png ...