- HTML5 Web Application Development By Example Beginner's Guide
- J.M. Gustafson
- 279字
- 2021-08-13 16:50:23
Shadows
Adding shadows to elements and text is simple in CSS3. Use shadows to make certain elements really stand out and give a more natural look to your UI. There are many options for adding shadows, such as size, position, and color. Shadows don't always have to be behind elements and text; they can frame, highlight, and add effects to them too.
Box shadows
In addition to rounded corners, you can add shadows to elements using the new CSS3 box-shadow
property. The box-shadow
property takes a number of parameters that tells it how to draw the shadow:
box-shadow: h-offset v-offset blur-radius spread-radius color;
Here is an explanation of the parameters:
h-offset
: The horizontal offset of the shadow. Negative values put the shadow to the left of the element.v-offset
: The vertical offset of the shadow. Negative values put the shadow above the element.blur-radius
: Determines the blur amount; the higher the number, the more blur (optional).spread-radius
: The size of the shadow. If zero, it's the same size as the blur (optional).color
: The color of the shadow (optional).inset
: Addinset
to change shadow from outer to inner (optional).
Note
You can produce some interesting effects other than shadows with the box-shadow
property. You can give an element an inner or outer glow by setting the offset
values to zero and adjusting the blur and spread (see the previous two examples).

Text shadows
In addition to box shadows, CSS3 has support for text shadows using the text-shadow
property. It works nearly identically to box-shadow
and uses almost all the same parameters:
text-shadow: h-offset v-offset blur-radius color;
Like box-shadow
, you can produce some interesting effects, such as glowing text:

- JavaScript修煉之道
- C語言程序設計案例教程(第2版)
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- FreeSWITCH 1.6 Cookbook
- 運用后端技術處理業務邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- Node.js:來一打 C++ 擴展
- AIRIOT物聯網平臺開發框架應用與實戰
- Visual C#.NET Web應用程序設計
- Java Web開發實例大全(基礎卷) (軟件工程師開發大系)
- jQuery技術內幕:深入解析jQuery架構設計與實現原理
- UI設計基礎培訓教程(全彩版)
- Java EE 8 and Angular
- ASP.NET Core and Angular 2
- Unity 5 Game Optimization
- Learning ROS for Robotics Programming