I am having a problem with covering the background in CSS.
Before:
JavaScript
x
6
1
.main-bg {
2
background: no-repeat url("../../images/main_bg.jpeg");
3
height: 100vh;
4
color: white;
5
}
6
After:
JavaScript
1
6
1
.main-bg {
2
background: no-repeat url("../../images/main_bg.jpeg") cover;
3
height: 100vh;
4
color: white;
5
}
6
Anyone know how to fix this? Thanks!
Advertisement
Answer
You cannot have cover
alone in the background property. You are obliged to define the position as well:
JavaScript
1
2
1
background: no-repeat url("../../images/main_bg.jpeg") center/cover;
2
Or add background-size: cover