When the height is set to 100vh, it results in a vertical

I am encountering an issue with the 100vh height setting, as it is causing a vertical scrollbar to appear. The problem arises when embedding external content in the widget-holder div, which has a height set to 100vh. Despite this, the content within the widget-holder exceeds the height of the parent div and triggers the appearance of a vertical scrollbar.

If I attempt to resolve this by removing the fixed header, the vertical scrollbar disappears. However, eliminating the fixed header is not a viable option. Alternatively, reducing the height within the widget-holder div results in some content being cut off visually, making it impossible to decrease the height accordingly.

I am seeking a solution that will allow the widget-holder's content to fit perfectly within the parent div's height.

html {
  --banner-menu-width: 250px;
  --ps-facets-width: 280px;
  --left-column-width: 349px;
  --main-column-width: 890px;
  --right-column-width: 0px;
}

* {
  box-shadow: none;
  margin: 0;
  padding: 0;
  border: 0;
}

body {
  caret-color: #4181af;
  font-size: 12px;
  line-height: 142%;
  margin: 0;
  overflow-y: scroll;
  background-color: #f3f3f4;
  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  height: 100%;
}

#app {
  display: grid;
  grid-template-columns: 0 250px auto;
  grid-template-rows: auto;
}

#app-content {
  background-color: #f3f3f4;
  grid-column: 3;
  display: grid;
  grid-template-columns: 100%;
  /* height: 100vh; */
}

#fixed-header {
  display: grid;
  grid-template-columns: 100%;
  background-color: antiquewhite;
  top: 0;
  position: sticky;
  z-index: 400;
  height: 60px;
}

#app #dynamic-style {
  visibility: hidden;
  grid-column: 1;
}

#app #banner {
  grid-column: 2;
  grid-row-start: 1;
  grid-row-end: -1;
  min-height: 100vh;
  max-height: 5000px;
  display: flex;
  justify-content: stretch;
  position: fixed;
  width: var(--banner-menu-width);
  z-index: 450;
}

#app #banner .banner-background {
  background: #223645;
  z-index: 500;
  align-self: stretch;
  width: 100%;
}

.dashboard-container {
  height: 100%;
}

.widget-holder {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: Arial, sans-serif;
  background: aqua;
}
<div id="app" class="grid-container">
  <div id="dynamic-style"></div>
  <div id="banner">
    <div class="banner-background"></div>
  </div>
  <div id="app-content" class="regular-workspace">
    <div id="fixed-header"></div>
    <div class="dashboard-container">

      <div class="widget-holder"></div>

    </div>
  </div>
</div>

Answer №1

Are you in need of this information?

To achieve this result, I simply calculated the screen height minus the banner height.

.dashboard-container {
    height: calc(100vh - 60px);
}

.widget-holder {
    display: flex;
    flex-direction: column;
    height: 100%;
    font-family: Arial, sans-serif;
    background: aqua;
}

Answer №2

Make your header sticky to take up space and adjust the top position of the page for its sibling elements. You can calculate the height of the header by subtracting it from the widget-holder's height.

.widget-holder {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    font-family: Arial, sans-serif;
    background: aqua;
  }

This solution worked in my tests.

Alternatively, you could utilize Grid layout correctly, such as:

#app-content {
    background-color: #f3f3f4;
    grid-column: 3;
    display: grid;
    grid-template-columns: 100%;
    grid-template-rows: 60px 1fr;
    height: 100vh;
  }
.widget-holder {
    display: flex;
    flex-direction: column;
    height: 100%;
    font-family: Arial, sans-serif;
    background: aqua;
  }

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

Switch up the hover color of the dropdown menu in the Bootstrap navbar

I'm struggling to change the hover color of the dropdown menu in the navigation bar. Can anyone please help me with this? Here is my HTML code. How can I change the hover color using CSS? <div class="navbar navbar-inverse" id="menu"> <di ...

Utilizing a Text Box, HTML, and Javascript to Showcase a PDF within an iFrame

Is there a way to add a form on a Sharepoint page that prompts users to input the URL of a PDF document, which will then be displayed in an iFrame on the same page? I've come across some code that achieves this with an image, but I'm struggling ...

Angular's table data display feature is unfortunately lacking

Below is a simple HTML code snippet: <div class="dialogs"> <div id="wrapper" > <p>{{createTestingConstant()}}</p> <ng-container *ngFor="let one of contacts"> <p>{{one ...

tips for positioning images and text in the center using css classes

Here's what I currently have: http://jsfiddle.net/nCs88/ Here's my goal: As a beginner, I am struggling to center the button images with the text. Any help would be greatly appreciated as this has been frustrating me for hours. ...

I'm curious about the meaning behind this code snippet: `$Odd = ($Odd == "even") ? "odd" : "even";`. Any ideas?

<?php $Odd = "even"; $query = $MySQLi->query("SELECT id, look, username, motto FROM users WHERE rank = '7'"); if($query->num_rows > 0): while($UserRow = $query->fetch_assoc()) { $Odd = ($Odd == "even") ? "odd" : "even"; ?&g ...

Guide to populating a dropdown list using an array in TypeScript

I'm working on a project where I have a dropdown menu in my HTML file and an array of objects in my TypeScript file that I am fetching from an API. What is the best approach for populating the dropdown with the data from the array? ...

execute javascript code found in the html document

Currently, I have a bash script that utilizes curl to download a page. Then, it uses grep and sed to extract javascript within the html block to a file. Following this, I use node to evaluate and leverage the downloaded javascript. Here is an example: cur ...

What is the best way to implement this design using CSS or JavaScript?

I would like to enhance the appearance of my school website during these challenging times of the pandemic by adding some CSS or JavaScript elements. However, I am unsure how to go about it. ...

How to create a vertically scrollable div within another div by utilizing scrollTop in jQuery

I need assistance with scrolling the #container div inside the .bloc_1_medias div. The height of #container is greater than that of .bloc_1_medias. My goal is to implement a function where clicking on the "next" and "previous" text will scroll the #contai ...

Modify the standard width setting in my css file

I'm looking to adjust my default width in the CSS file so I can incorporate an HTML5 animation on my website. Here's what I've placed on the site: <div id="nakuru_hype_container" style="margin:auto;position:relative;width:100%;height:33 ...

Align content to the center column with a combination of right-alignment and left-al

This question poses an interesting challenge, but I will do my best to articulate it: I have a central column of content and I am looking to incorporate columns on the left and right of it that seamlessly "hug" the middle column. How can I consistently ce ...

Ways to center an image within a div using Bootstrap 4

I am currently using Bootstrap version v4.0.0-beta.3 and facing a challenge with aligning an image in the absolute center of a fixed-height div tag. While I have successfully aligned the image horizontally using the mx-auto and d-block classes, I am strugg ...

Conceal table columns on an HTML page using CSS styling

HTML: <table class="list qy"> <tr> <td>cell1</td> <td class="q">cell2</td> <td>cell3</td> <td class="y">cell4</td> </tr> </table> CSS: table.qy td.q, table.qy td.y { displ ...

When scrolling, the sticky <td> element on the table is overlapping with the sticky <th> header, causing the <td> border to disappear. What is the solution to fix this issue?

I am trying to set up a table that has a fixed header when scrolling up and a fixed first column when scrolling left. I have applied 'position: sticky' with 'top:0' for the header and 'left:0' for the first column. However, I ...

Issue with embedding icon within input field in Bootstrap version 4.1

I am currently implementing a project using Angular 6 along with the latest version of Bootstrap v4.1. I am attempting to create a reactive form with icons within input fields. As there is no direct way in bootstrap to place icons on the left side of input ...

What is the method for increasing the left margin of the back button on the default header in React Native?

My attempt to increase the space on the back button from the left side of the header in my React Native code has been unsuccessful. headerStyle: { paddingLeft: 60 } https://i.stack.imgur.com/0RFb0.png I also experimented with adding margin ...

Iphone not picking up media queries, while browser resize is working perfectly

Hey there, I'm currently using a theme called Bones on my WordPress site, but I'm encountering some difficulties with the responsive menu on my iPhone. Oddly enough, when I manually resize the window, the menu seems to work just fine. Here' ...

resembling the nth-child selection for even elements within a list wrapped in <ul> tags

I recently utilized ng-repeat to iterate over a ul element. Unfortunately, I've run into an issue where I can't simply use nth-child(even) to change the background color of every other ul element. Does anyone have any alternative solutions or s ...

Ordering styles in Material UI

I've spent countless hours customizing this element to perfection, but the more I work on it, the more of a headache it gives me. The element in question is an outlined TextField, and my focus has been on styling its label and border. Initially, I th ...

Executing the command in the Windows Command Prompt by utilizing an HTML button

When a button on my HTML page is clicked, I want to execute the command python abc.py in the Windows command prompt. The python file is stored at C:/abc.py. I'm looking for guidance on how to code the HTML page to achieve this functionality. Any assis ...