Gray section-title Bar responsive Height Issue

I recently added some custom CSS from another post on here to make the background-image of my section-title bar responsive. However, the gray background behind still shows. How can I get the height of the div to be responsive as well?
Here’s the code I added to make the image responsive: {
    background-size: contain;
    background-repeat: no-repeat !important;
    padding: 0px;

I’d like the height of the gray bar to automatically adjust to the height of the image so that it doesn’t show. Changing the background color to white also isn’t an option, because it would leave too much blank space below the image.