On my page, I want to have a hero section with an image(a gif) and I want it to have the same width(100% of the page) but an adjustable height(as I resize my window).
But for some reason, the height of my image goes a maximum of 400px (which is also my min-height), which leads to a stretched image like:
Here is my code, (uses Bulma):
.hero {
background: url("https://cdn-images-1.medium.com/max/1600/1*XI3beonBnOwp-y5BwNOqCw.gif");
background-size: 100% 100%;
background-repeat: no-repeat;
min-height:400px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" rel="stylesheet"/>
<body class="has-navbar-fixed-top">
<nav class="navbar is-info is-fixed-top">
<div class="container has-text-centered">
<div class="navbar-brand" style="flex-grow: 1; justify-content: center;">
<a class="navbar-item" href="https://bulma.io" >
<img src="https://vignette.wikia.nocookie.net/narutofanon/images/c/cc/Fdl-logo.svg/revision/latest?cb=20130812063152">
</a>
</div>
</div>
</nav>
<section class="hero is-large has-text-centered">
</section>
</body>
Here is the JSFIDDLE : https://jsfiddle.net/8xjtknaf/2/
Is there any way, I can avoid setting a min-height value because it just feels hacky. Is there a proper way for my code to detect the size of my image and scale accordingly?