Struggling with setting container height to 100% in Angular/Material and encountering difficulties

Having some trouble creating a new UI mockup using Angular and Material design elements. I can't seem to get the area below my toolbar to fill the remaining vertical height of the page.

Check out my code example here

Despite setting html, body { height: 100%; }, it hasn't solved the issue. I've considered using flexbox but I'm not very familiar with it.

Any assistance would be greatly appreciated.

UPDATES & SOLUTION Decided against using flexbox as a quick fix, opting for a CSS calculation instead by utilizing height: 100vh and adjusting for any overlap.

mat-sidenav-container {
    height: calc(100vg - 64px);
}

Noticed that when resizing the window, the responsive nature of the material elements causes the toolbar height to shrink, leaving a blank space below the content. Added a media query to account for this scenario:

mat-sidenav-container {
  height: calc(100vh - 64px);
}

@media (max-width: 600px) {
    mat-sidenav-container {
        height: calc(100vh - 56px)
    }
}

This might not be the most optimal solution, but it's the one that seems to work for now.

Answer №1

So, I managed to make some adjustments based on the code you shared with me:

Included style="height:100%" in the following classes:

html, blitz-app, added it to another div, and also included it in mat-sidebar-container

Edit: Modified the style of the html tag to: height:calc(100% - 64px); Explanation: The 64px accounts for the toolbar's height

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

I implemented these changes directly through the Chrome browser debugging console as I couldn't pinpoint the exact classes used in the code. However, I believe you should be able to do so :)

Hopefully, this information proves helpful.

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

HTML image identifier and canvas elements

Greetings! I have a question that I've been struggling to find an answer for on Google. I'm attempting to draw an image on a canvas and initially used the "new" constructor ( ballPic = new Image(); ballPic.src = "ball.png" ) which worked fine. Ho ...

"Troubleshooting a CSS Animation Problem: Button Animation Glitch

I was working on a code snippet with the following structure: shakingErr class from CSS was not being applied correctly when the user clicked submit with empty/wrong fields. How can this be resolved so that the shaking error animation is triggered proper ...

Creating a design with CSS that features three main content columns of equal height, all of which are scrollable and have fluid heights, along with a sticky

After extensive research through various online resources, I have yet to find a solution to my specific CSS layout inquiry regarding "3 equal-height columns with a 'really' sticky footer". The desired layout includes the following components: ...

An error was encountered while attempting to establish a ngmodule service creation

I'm currently working on setting up a servicesModule to house all of my services. The first service I'm attempting to transfer is my remote service, but I'm encountering an error that I can't seem to troubleshoot. Uncaught Error: Unexp ...

Error in Javascript: Attempted to save content of div element to text file, but encountered a TypeError as null is not recognized

I've been attempting to save the content of a div element into a text file but encountered the following error: TypeError: null is not an object (evaluating 'link.href = generateTxtFile('dummyText.innerText')') What seems to be ...

Unable to retrieve HTML code from a webpage using its URL address

Currently, I am trying to retrieve the HTML code of a specific webpage located at . My initial attempts using HttpClient were unsuccessful due to exceeding request processing time. It seems like this website may have anti-bot protection in place. I attempt ...

Adding HTML content inside an iFrame at a specific cursor position in Internet Explorer

Does anyone know a method to insert HTML into an iFrame specifically for IE? I have been using execCommand insertHtml in Chrome and Firefox, but it doesn't seem to work in IE. I was able to paste HTML into a content editable div using pasteHTML, howe ...

What is the process of retrieving a boolean value from a function that listens to an observable of a different function?

I'm currently facing an issue with my code. I have a ProductService which includes a boolean function called validateProductsBeforeChanges. Within the validateProductsBeforeChanges function, I am calling another service named OrderService, which retu ...

Floating label hides the textbox text with a unique style

I'm trying to create a floating label effect for textboxes in my form that moves up on hover and focus. However, I'm running into an issue where the text gets hidden when the label moves up. Below is the HTML and CSS code I've been working ...

Use HTML to showcase an image that dynamically changes based on the outcome of a query function

Hello there, I hope my inquiry is clear enough. I apologize for reaching out as I am unsure where to begin and what exactly I should be focusing on. Currently, I have an image displayed in an HTML page like this: <div id="tag_sunrise_sunset"><p ...

The attribute 'map' is not found on the data type 'Observable<[{}, {}]>'

Struggling to incorporate map, PublishReplay, and other rxjs functions into Angular6, I keep encountering a compilation error stating "Property 'map' does not exist on type 'Observable<[{}, {}]>'" every time. The same issue arises ...

jQuery Summation: A Step-by-Step Guide

Hello everyone, I am a new member of this forum and I am looking forward to learning and contributing with all of you. I have encountered a problem that I tried to solve on my own but couldn't figure it out. Would anyone be able to lend me a hand? H ...

Modify the hue of a background image in PNG format

I'm currently using a CSS selector on my site to display an icon for external links on any href that isn't directing to my own domain. Here's the code snippet I'm referring to: a[class=" external-link"]::after { content: url(data:im ...

Issue with duplicate selectors not being merged in SASS partials

Is there a way for SASS to combine duplicate CSS selectors from multiple files into a single output file? In my current setup, I have the same CSS selector present in separate SASS partials files that are all included in a master file. For example: File1 ...

Get the name of the form I am submitting using jQuery

Looking to create a jQuery script that can serialize the formData being submitted from any HTML page. The challenge arises when there are multiple forms on a single page - how do I distinguish which form is being submitted? My goal is to track activities o ...

Footer positioned centrally on screen

My webpage footer seems to be misplaced, appearing in the middle of my content instead of at the bottom where it should be. Surprisingly, the code for the footer works perfectly on other pages. Any suggestions on why this might be happening? I've sco ...

VS code is showing the directory listing instead of serving the HTML file

Recently, I attempted to use nodejs to serve the Disp.html file by following a code snippet from a tutorial I found on YouTube. const http = require("http"); const fs = require("fs"); const fileContent = fs.readFileSync("Disp.html& ...

What is the reason for preserving the height to width ratio in the <img> tag?

When I write a simple code like this: <img src="mycat.jpg" height="300px";> I noticed that if the image is very large, the height will be reduced to 300px, and the width will automatically adjust to fit the new height. I expected ...

Is there a way to ensure that all images are uniform in size and aligned in a row?

I have an upcoming exam covering various topics that the teacher and I worked on together today, with the exception of the photo tab. The teacher instructed me to submit it within a few days, completed in full. I have independently completed everything o ...

Creating a Stylish ExtJS Container with CSS: A Step-By-Step

I've been experimenting with the ExtJS properties cls, bodyCls, and componentCls but unfortunately, I'm not achieving the desired outcome. As an illustration: Ext.create('Ext.form.Panel', { renderTo: document.body, title: &apo ...