Background Image Settings (background-size, repeat, position)
Goal: Control size, repeat, and position of background images.
1. Background size
.hero {
background-image: url('banner.jpg');
background-size: cover;
}
2. Repeat
.pattern {
background: url('pattern.png');
background-repeat: repeat-x;
}
3. Position
.header {
background-position: center top;
}
4. Fixed background
.bg {
background-attachment: fixed;
background-size: cover;
}
Tips:
- Use
coverfor hero sections. fixedgives a parallax-like effect.
Background Image Settings (background-size, repeat...