Have this image inside a section which has to be forced to have the exact same height of the section height. I worked this out but it doesn't seems to work on resizing.
Code I have
HTML
<section id="header-bg">
<img src="images/background.png">
</section>
CSS
$header-bg-top: 80px;
$header-bg-height: 620px;
#header-bg {
position: relative;
top: $header-bg-top;
max-height: $header-bg-height;
overflow: hidden;
border-bottom: 1px solid red;
img {
background: url(../images/background.png);
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
}
Result on resized screen:
I already found a lot on the internet, but this is not working out for me.
CSS - Expand float child DIV height to parent's height
How to Force Child Div to 100% of Parent's Div Without Specifying Parent's Height?
http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks