Backgrounds
๐ Covered in this chapter:
background-color ยท background-image ยท background-size ยท background-position ยท background-repeat ยท background-attachment ยท Multiple Backgrounds ยท Gradients ยท Overlays
Welcome to Chapter 30: Backgrounds โ part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Background Properties
.hero {
background-color: #1e293b;
background-image: url('/images/hero.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}
background-size: coverโ fill container, crop if neededbackground-size: containโ full image visiblebackground-positionโ top, center, 50% 30%, etc.background-attachment: fixedโ parallax-like effect
2Multiple Backgrounds & Overlays
CSS
.hero-overlay {
background:
linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.7)),
url('/images/hero.jpg') center / cover no-repeat;
min-height: 60vh;
color: #fff;
}
First listed background top layer โ gradient overlay image meeda render avuthundi.