- 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:

- Instant Node Package Manager
- C語(yǔ)言程序設(shè)計(jì)實(shí)踐教程(第2版)
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程
- 程序員面試筆試寶典
- 算法精粹:經(jīng)典計(jì)算機(jī)科學(xué)問(wèn)題的Java實(shí)現(xiàn)
- 算法訓(xùn)練營(yíng):入門(mén)篇(全彩版)
- Java技術(shù)手冊(cè)(原書(shū)第7版)
- Hands-On JavaScript High Performance
- C語(yǔ)言程序設(shè)計(jì)
- Getting Started with Nano Server
- 監(jiān)控的藝術(shù):云原生時(shí)代的監(jiān)控框架
- 多媒體技術(shù)及應(yīng)用
- Java程序設(shè)計(jì)
- C# 7 and .NET Core 2.0 Blueprints
- Backbone.js Patterns and Best Practices