0

All I want is to place background image for div for 100% width. Could you please help me to find my mistake.

html

  <div class="slogan_background"> 
    <h2>Slogan</h2> 
    </div>

css

 background-image: url("../img/bg.jpg");
 background-repeat: no-repeat;
 background-position: center; 
 width:100%;
 min-height: 526px; 
EducateYourself
  • 971
  • 2
  • 12
  • 32

3 Answers3

1

Your code looks good but maybe you didn't set height and width for body tag. Try adding this to your css

html, body{
  width:100%;
  height:100%;
}

Also set padding and margin to 0 to remove spaces from the side

.slogan_background{
  padding:0;
  margin:0;
}
Nakib
  • 4,293
  • 7
  • 22
  • 45
1

If I understand the issue correctly, this might help:

background-size: cover;
cocoa
  • 3,636
  • 7
  • 28
  • 56
1

Add the backgroun-size:100% 100%; duplicate here

Community
  • 1
  • 1
whatever
  • 334
  • 2
  • 16