I'm having an issue with a full-width div
containing a background image on my responsive website. Everything looks fine on desktop, but when I switch to responsive mode using Chrome Dev Tools, a horizontal scroll bar appears that I can't remove with overflow-x: hidden
, max-width: 100%
, or min-width: 100%
. I've already tried a solution from Stack Overflow without success. (Bootstrap 4 is being used)
Here's the code snippet:
/* CSS for Desktop */
.country-background-img {
background: url('https://placeimg.com/1000/695/animals');
background-repeat: no-repeat;
background-size: cover;
height: 695px;
padding: 60px 30px 0 30px;
margin-top: 50px;
}
/* Responsive CSS */
.country-background-img {
height: auto;
text-align: center;
background-attachment: fixed;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div class="row">
<div class="col-12 country-background-img img-fluid" id="countryBackgroundImg">
<div class="col-lg-6 offset-lg-6 col-md-12 col-sm-12 col-12">
<p class="about-country-title" id="aboutCountryTitle">About Brazil</p>
<p class="about-country-text" id="aboutCountryText">Text 1</p>
<p class="about-country-text">Text 2</p>
<p class="about-country-text">Text 3</p>
</div>
</div>
</div>