Search code examples
vmware-clarity

Clarity Card Fill to Screen Height


Using Clarity and Angular 6, I have a card in the main content area that I'd like to have fill the length of the current view (no more, no less). The only way I found that comes close is to set the height to "-webkit-fill-available" (only using Chrome right now).

The problem with this is that there seems to be a tiny bit of space at the bottom that's causing the content area to show a scroll bar.

Ideally I'd like to never see a scrollbar in the content area and make all the content fit within the current screen height.

Here is a stackblitz example that demonstrates the problem.


Solution

  • Your solution is not a standard and would not work on IE/Edge, and might not work well with Safari per https://caniuse.com/#search=fill-available.

    You could try giving it a height: calc(100vh - 5.5rem);, which gives the card a height of the view port, but subtracts the heights of the header bar and margins of the card and content areas. Ultimately, to use CSS to calculate heights you need to know what other elements are on the page and calculate against those known heights, or else you'd have to do something with JavaScript to inspect the elements of the page to find the available space.