๐จ CSS COURSE โ MODULE 11: BACKGROUNDS & BORDERS
๐ File: backgrounds.md
๐จ Backgrounds & Borders
๐ Introduction
CSS backgrounds and borders control:
- visual style
- depth
- UI appearance
- modern design effects
๐ They are essential for building professional interfaces.
๐จ 1. Background Color
div {
background-color: lightblue;
}
โ Sets solid background color
๐ผ๏ธ 2. Background Image
div {
background-image: url("image.jpg");
}
โ Adds image as background
๐ 3. Background Size
div {
background-size: cover;
}
Values:
coverโ fills areacontainโ fits inside
๐ 4. Background Position
div {
background-position: center;
}
โ Controls image placement
๐ 5. Background Repeat
div {
background-repeat: no-repeat;
}
Options:
- repeat
- no-repeat
- repeat-x
- repeat-y
6. Gradient Backgrounds (VERY IMPORTANT)
div {
background: linear-gradient(to right, blue, purple);
}
โ Modern UI design feature
๐ง Gradient Types
Linear Gradient
background: linear-gradient(to right, red, blue);
Radial Gradient
background: radial-gradient(circle, red, yellow);
๐งฑ 7. Borders
div {
border: 2px solid black;
}
Structure:
border: width style color;
๐ฏ 8. Border Radius (MODERN UI)
div {
border-radius: 10px;
}
โ Makes rounded corners โ Used in all modern websites
๐ง 9. Box Shadow (DEPTH EFFECT)
div {
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
}
โ Adds shadow โ Creates 3D effect
๐งฉ Real Example
<div class="card">Hello CSS Design</div>
.card {
width: 200px;
padding: 20px;
background: linear-gradient(to right, #4facfe, #00f2fe);
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
color: white;
}
๐จ Modern UI Combination
background + border-radius + box-shadow
โ This is what real apps use
โ ๏ธ Common Mistakes
- Using too many background images โ
- Overusing shadows โ
- No consistent border radius โ
- Poor color contrast โ
๐ฏ Pro Tip
๐ Modern design rules:
- soft shadows (not harsh)
- smooth gradients
- rounded corners
- simple colors
๐งช Mini Exercise
Create:
- A card with gradient background
- A box with border + radius
- A section with background image
- A shadowed button
- A full-width banner with gradient