In my responsive website, I have a div
that is full width, and it contains a background image (placed in the CSS file). On the desktop, everything looks fine. However, when I view the page in responsive mode (I'm using Chrome Dev Tools), I get a horizontal scroll bar that I can't get rid off with overflow-x: hidden
, nor with max-width: 100%
or min-width: 100%
I've tried this answer and it doesn't work for me. (I'm using Bootstrap 4)
Here's my code:
/* 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>