I have an image which I want to be displayed inside my div. I want it to occupy my hero section.
Problem is, when I use contain
, it doesn't fill the whole div and empty space is left after image. When I use cover
, it doesn't show complete image rather it clips/crop majority of the image. Am I doing anything wrong?
body {
text-align: center;
margin: 0;
}
.hero {
background-image: url("https://img.theculturetrip.com/450x/smart/wp-content/uploads/2018/07/shutterstock_697606678.jpg");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 300px;
}
<body>
<div class="hero"></div>
</body>