text-shadow: 2px 2px;
}
Note: Internet Explorer 9 and earlier versions do not support the text-shadow attribute
Example 2: Change the color for the shadow
h1 {
text-shadow: 5px 5px violet;
}
Example 3: Add blur effect - blur the shadow
h1 {
text-shadow: 5px 5px 10px violet;
}
Example 4: Shadow highlights neon style
h1 {
text-shadow: 0 0 3px red;
}
If you want a colorful shadow, add more by adding the same values for the property and separating the values by commas.
For example: Shadow style neon lights are green and yellow
h1 {
text-shadow: 0 0 5px gold, 0 0 7px #0000FF;
}
Example: Shadow combines 3 colors
h1 {
color: white;
text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}
Example: Use text-shadow to create a simple border around the text
h1 {
color: #e9d8f4;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
The box-shadow attribute used to create shadows for box-like elements, works with borders, makes the display element stand out similar to a 3D box.
box-shadow: h-offset v-offset blur spread color
Box-shadow consists of 5 parameters:
Example 1: Simplest, you format the shadow vertically 10px, width 10px, the result is as follows:
div {
box-shadow: 10px 10px;
}
Example 2: Change the color for the shadow
div {
box-shadow: 10px 10px midnightblue;
}
Example 3: Add blur effect - blur the shadow
div {
box-shadow: 10px 10px 5px midnightblue;
}
Example 4: Add shadows to the elements pseudo-element :: before and :: after to create more special effects:
#boxshadow {
position: relative;
box-shadow: 1px 2px 4px rgba(0, 0, 0, .5);
padding: 10px;
background: white;
}
#boxshadow img {
width: 100%;
border: 1px solid #8a4419;
border-style: inset;
}
#boxshadow::after {
content: '';
position: absolute;
z-index: -1; /* ẩn shadow phía sau hình ảnh */
box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
width: 70%;
left: 15%; /* một nửa của 30% còn lại */
height: 100px;
bottom: 0;
}
Example 5: Create a 3D box, calendar format
div.card {
width: 250px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
text-align: center;
}