How to make div 100% of display height when I have to exclude the Navbar

旧城冷巷雨未停 提交于 2021-02-11 18:25:00

问题


One question I have a div below a navbar. I want that the div has 100% of the remaining space and add a nice padding as Frame around it. It should not be scroll able. Also I cant bind the navbar somehow because in the project its completely different component.

I try to simplify my code.

nav {
  min-height: 80px;
  background-color: blue;
}

.take-page-height {
  padding: 1.5%;
  background-color: red;
  /* added for demonstration */
}

.welcome-div {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  word-wrap: break-word;
  background-color: green;
  background-clip: border-box;
}
<meta name="viewport" content="width=device-width,initial-scale=1" />

<nav>Hello world</nav>
<div class="take-page-height">
  <div class="welcome-div">
    <div class="col-md-12 center-text">
      <div>
        <h1>Hello</h1>
      </div>
    </div>
  </div>

The question is how I can make the div 100% of remaining space.

  1. is not scrollable
  2. cant integrate the navbar for example in a gridsystem
  3. A nice padding frame is around the container.

Thanks


回答1:


This should help you: Make a div fill the height of the remaining screen space

Basically you should use flexbox to make the div grow and fill up the rest of the page. Are you familiar with flex box? If not you can read here: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox



来源:https://stackoverflow.com/questions/65373908/how-to-make-div-100-of-display-height-when-i-have-to-exclude-the-navbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!