To use the fulls creen height, use height: 100vh;
. To use the full screen width, use: width: 100vw;
.
The main issue will be, that it is a definite height of the content area. Means paddings, margins and border will overflow it and you get scrollbars by default.
To counter the issue the first approach should be to reset the default body margins with: body { margin: 0; }
.
However the padding and border will still cause an overflow. The simple solution without using the calc function
, is to change the default box behavior. The default box behavior is: box-sizing: content-box;
. If you change it to box-sizing: border-box;
the paddings and border will no longer cause an issue.
PS: I Added a red background color to the parant div for demonstration.
Edit, I moved the sizing to the body. Also declared the body as grid. Its set that the navbar will take the height that navbar would need and the text-area will fill up the remaining space. This is done by giving the row height of the navbar within the grid-template a height of min-content. So it will only be as height as the navbar requires. So its up to you if you declare it with a relative or fixed height or simply by using the contents height.
body {
margin: 0;
box-sizing: border-box;
height: 100vh;
width: 100vw;
display: grid;
grid-template-rows: min-content auto;
}
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;
}
<nav>Navbar here</nav>
<div class="take-page-height">
<div class="welcome-div">
<div class="col-md-12 center-text">
<div>
<h1>Hello</h1>
</div>
</div>
</div>
</div>