Here is a straightforward and easy-to-understand code snippet:
HTML markup:
<div class="jumbotron text-center top-jumbotron">
</div>
CSS:
.top-jumbotron {
background: #ffcc00;
background-image: url('../../bootstrap/img/home-page-banner.jpg');
background-size: 100% auto;
padding: 0px;
margin: 0px;
border: none;
}
I have an image that is 2880px wide, and it displays perfectly when I specify the width in pixels using CSS. However, I am hesitant to set hard-coded measurements because I want the div to adapt to all screen sizes from mobile to Retina. Is there a way to make the image appear while using a percentage value for background-size? I prefer not to use the <img>
tag in HTML as I plan to overlay text and other elements on the div, hence the background approach.