CSS box-shadow editable templates
By Dr. Roger Ianjamasimanana
HTML/CSS Editor
x
1
<!-- Write your HTML/CSS code here -->
2
<!-- Click 'Run code' to see the output below -->
3
<!DOCTYPE html>
4
<html lang="en">
5
<head>
6
<meta charset="UTF-8">
7
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8
<title>CSS box shadow examples</title>
9
<style>
10
body {
11
padding: 20px;
12
font-family: Arial, sans-serif;
13
}
14
.box-container{
15
display:flex;
16
padding:20px;
17
flex-wrap:wrap;
18
justify-content:center;
19
background-color:white;
20
gap:20px;
21
}
22
.box {
23
width: 150px;
24
height: 150px;
25
border-radius: 8px;
26
display: flex;
27
font-size: 14px;
28
align-items: center; /* Vertically center the content */
29
justify-content: center; /* Horizontally center the content */
30
text-align: center; /* Center align multi-line text */
31
color: black;
32
font-weight: bold;
33
}
34
</style>
35
</head>
36
<body>
37
38
<div class="box-container">
39
<!-- Example 1 -->
40
<div class="box" style="box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); background: #f5f5f5;">Subtle Shadow</div>
41
42
<!-- Example 2 -->
43
<div class="box" style="box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5); background: #fff;">Medium Shadow</div>
44
45
<!-- Example 3 -->
46
<div class="box" style="box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2); background: linear-gradient(to bottom, #e66465, #9198e5);">Gradient Shadow</div>
47
48
<!-- Example 4 -->
49
<div class="box" style="box-shadow: inset 0px 5px 10px rgba(0, 0, 0, 0.2); background: #f8f9fa;">Inset Shadow</div>
50
51
<!-- Example 5 -->
52
<div class="box" style="box-shadow: -5px -5px 10px rgba(255, 255, 255, 0.7), 5px 5px 10px rgba(0, 0, 0, 0.2); background: #e0e0e0;">Neumorphism</div>
53
54
<!-- Example 6 -->
55
<div class="box" style="box-shadow: 0 0 20px rgba(0, 150, 136, 0.5); background: #009688; color: white;">Glow Effect</div>
56
57
<!-- Example 7 -->
58
<div class="box" style="box-shadow: 0px 5px 15px rgba(255, 87, 34, 0.5); background: #ff5722; color: white;">Vibrant Shadow</div>
59
60
<!-- Example 8 -->
61
<div class="box" style="box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.1), 0px 4px 6px rgba(0, 0, 0, 0.1); background: #ffffff;">Layered Shadow</div>
62
63
<!-- Example 9 -->
64
<div class="box" style="box-shadow: 0px 0px 10px 3px rgba(0, 0, 255, 0.3); background: #4c69ba; color: white;">Blue Glow</div>
65
66
<!-- Example 10 -->
67
<div class="box" style="box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.3), -10px -10px 30px rgba(255, 255, 255, 0.3); background: #e8e8e8;">Double Neumorphism</div>
68
69
<!-- Example 11 -->
70
<div class="box" style="box-shadow: 0px 20px 25px rgba(0, 0, 0, 0.1); background: #f0f0f0;">Drop Shadow</div>
71
72
<!-- Example 12 -->
73
<div class="box" style="box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3), -5px -5px 15px rgba(0, 0, 0, 0.1); background: linear-gradient(145deg, #d8d8d8, #f0f0f0);">Soft Neumorphism</div>
74
75
<!-- Example 13 -->
76
<div class="box" style="box-shadow: 0 10px 20px rgba(76, 175, 80, 0.4); background: #4caf50; color: white;">Green Glow</div>
77
78
<!-- Example 14 -->
79
<div class="box" style="box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.2), 0 5px 10px rgba(0, 0, 0, 0.2); background: #fff;">Inset Layer</div>
80
81
<!-- Example 15 -->
82
<div class="box" style="box-shadow: 0px 15px 30px rgba(0, 0, 0, 0.3); background: #f5f5f5;">High Shadow</div>
83
84
<!-- Example 16 -->
85
<div class="box" style="box-shadow: 5px 10px 20px rgba(0, 0, 0, 0.2); background: #e9ecef;">Diagonal Shadow</div>
86
87
<!-- Example 17 -->
88
<div class="box" style="box-shadow: 0px 0px 15px rgba(255, 0, 0, 0.5); background: #ff1744; color: white;">Red Glow</div>
89
90
<!-- Example 18 -->
91
<div class="box" style="box-shadow: -10px 10px 30px rgba(0, 0, 0, 0.3); background: #fff;">Offset Shadow</div>
92
93
<!-- Example 19 -->
94
<div class="box" style="box-shadow: 0px 10px 20px rgba(63, 81, 181, 0.5); background: #3f51b5; color: white;">Blue Accent</div>
95
96
<!-- Example 20 -->
97
<div class="box" style="box-shadow: 0px 20px 40px rgba(0, 0, 0, 0.1); background: #ffffff;">Elegant Shadow</div>
98
</div>
99
</body>
100
</html>
101
JavaScript Editor
xxxxxxxxxx
2
1
// Write your JavaScript here
2
Console Output
HTML Output
The box-shadow property in CSS allows you to add shadow effects around an element's frame. You can set multiple effects separated by commas. These shadows are drawn outside the element's frame — they don't affect the layout of the document.
Box-shadow basic syntax
The syntax of box-shadow is:
box-shadow: offset-x offset-y blur-radius spread-radius color;
Explanation
- offset-x and offset-y: these set the horizontal and vertical distances of the shadow. Positive values move the shadow right and down, respectively.
- blur-radius: (optional) defines how blurry the shadow is. The larger the value, the more blurred the shadow.
- spread-radius: (optional) expands or contracts the size of the shadow.
- color: sets the color of the shadow.
Simple example
A subtle shadow effect
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 200px;
height: 200px;
background: #f5f5f5;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<div class="box"> </div>
</body>
</html>
In this example:
- The box is 150px by 150px with a light background.
- The shadow is offset by 2px right and 2px down.
- It has a blur radius of 5px.
- The color is a semi-transparent black.
Multiple shadows
You can combine multiple shadows by separating them with commas:
<!DOCTYPE html>
<html>
<head>
<style>
.box-multiple {
width: 200px;
height: 200px;
background: #fff;
box-shadow:
2px 2px 5px rgba(0, 0, 0, 0.3), /* first shadow */
-2px -2px 5px rgba(0, 0, 0, 0.2); /* second shadow */
}
</style>
</head>
<body>
<div class="box-multiple"> </div>
</body>
</html>
Here, the element gets two shadows: one offset down-right and another offset up-left, creating a layered effect.
Inset shadow
By default, shadows are on the outside of an element. To create an inner shadow, use the inset keyword:
<!DOCTYPE html>
<html>
<head>
<style>
.box-inset {
width: 200px;
height: 200px;
background: #fff;
box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
</style>
</head>
<body>
<div class="box-inset"> </div>
</body>
</html>
The inset keyword changes the shadow from outer to inner, creating a sunken effect.
32 Views
0 Comments
Readers’ comment
Log in to add a comment
Author
Dr. Roger Ianjamasimanana