I have an absolute element that is the background. I can't set it as the div's background because it is animated and it requires 2 css classes. I simplified it to let you understand the problem.
I would like to set the height of this absolute element same of its parent, which, containing all the other elements, reaches the bottom of the page. So this absolute element that I use as background should cover all the background page, but inherit is not working.
I tried also height:100%
but it didn't work. It works only if I set manually the height, but doing like this is not responsive.
.stars {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
width:inherit;
height:inherit;
display:block;
}
.stars {
background:#000 url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
z-index:0;
}
.main-content {
display: flex;
width: 100%;
height: 100%;
flex-direction: column;
flex-wrap: wrap;
align-content: center;
justify-content: center;
align-items: center;
}
.home-container {
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
width: 100%;
z-index: 5;
}
.genericDiv1, .genericDiv2, .genericDiv3 {
width: 200px;
height: 200px;
}
.genericDiv1 {
background-color:#f00;
}
.genericDiv2 {
background-color:#00ff76;
}
.genericDiv3 {
background-color:#2900ff;
}
<body>
<div class="main-content">
<div class="stars"></div>
<div class="home-container">
<div class="genericDiv1"></div>
<div class="genericDiv2"></div>
<div class="genericDiv3"></div>
</div>
</div>
</body>
I want to specify that if I set the .main-content
class with a specific height it works. But as I said before, in this way it is not responsive.