Experiment with Multiple Shadow Effects
In this step, you'll explore advanced techniques for creating complex shadow effects using multiple box shadows. Open the index.html
file in the WebIDE and update its content with the following code:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Multiple Shadow Effects</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.card {
width: 300px;
height: 400px;
background-color: white;
border-radius: 10px;
/* Multiple shadow effect */
box-shadow:
/* Outer shadow */
0 10px 20px rgba(0, 0, 0, 0.1),
/* Inner shadow */ inset 0 -5px 10px rgba(0, 0, 0, 0.05),
/* Colored accent shadow */ 0 15px 25px rgba(0, 123, 255, 0.2);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 20px;
transition: transform 0.3s ease;
}
.card:hover {
transform: scale(1.05);
box-shadow:
0 15px 30px rgba(0, 0, 0, 0.2),
inset 0 -5px 10px rgba(0, 0, 0, 0.1),
0 20px 35px rgba(0, 123, 255, 0.3);
}
</style>
</head>
<body>
<div class="card">
<h2>Shadow Experiment</h2>
<p>Hover to see shadow effect!</p>
</div>
</body>
</html>
Key techniques for multiple shadow effects:
-
Layered Shadows:
- First shadow: Outer soft shadow
- Second shadow: Inner subtle shadow
- Third shadow: Colored accent shadow
-
Shadow Composition:
0 10px 20px rgba(0, 0, 0, 0.1)
: Soft outer shadow
inset 0 -5px 10px rgba(0, 0, 0, 0.05)
: Inner subtle shadow
0 15px 25px rgba(0, 123, 255, 0.2)
: Blue accent shadow
-
Hover Effect:
- Increase shadow intensity on hover
- Add scale transformation for interactive feel
Example visual output:
+------------------------+
| |
| [Card with Complex |
| Shadow Effects] |
| |
+------------------------+
Key points:
- Combine multiple shadows for depth
- Use
inset
for inner shadows
- Create interactive effects with hover