haitham sha
haitham sha

Reputation: 90

The background for the div does not fit from the left side and make an unwanted scroll

Hi guys I explain my problem in this image. enter image description here

I use this code to make a background to the div

.intro .bg-img{
     position: absolute;
     background: green url('https://static.pexels.com/photos/7350/startup-photos.jpg');
     background-size: cover;
     background-position: center;
     background-repeat: no-repeat;
     width:100%;
     height:350px;
     z-index: -1;
     opacity: 0.5;
}

here is the all code https://codepen.io/haithamsha/pen/LeVZVr

Upvotes: 0

Views: 30

Answers (1)

Oliver Cooke
Oliver Cooke

Reputation: 1059

Looking at your code you have CSS that applies a 1em padding to every div within the wrapper class.

To fix this you can apply padding: 0 !important; to your intro class.

.intro {
    grid-column: span 1;
    text-align: center;
    min-height: 350px;
    background-color: #fff;
    z-index: 1;
    position: relative;
    padding: 0 !important; /* Apply important here */
    margin: 0;
}

Or you need to remove the 1em padding from every div and be more granular with your padding.

.wrapper > div {
   /* background: #ddd; */
   padding: 1em; /*<-- Remove this*/
}

Hope that helps

Upvotes: 2

Related Questions