CSS skuggverktyg

Kaffe
Skuggor

Skapa skuggverktyg med CSS!

Håll muspekaren över mig!

CSS skuggverktyg

Genom att använda CSS kan du lägga till skuggor på text och element.

I vår tutorial kommer du att lära dig följande egenskaper:

  • text-shadow
  • box-shadow

CSS text shadow

CSS text-shadow Egenskapen lägger till skuggor till texten.

Den enklaste användningen är att endast specificera horisontell skugga (2px) och vertikal skugga (2px):

Text shadow effect!

Example

h1 {
  text-shadow: 2px 2px;
{}

Try it yourself

Lägg sedan till färg till skuggan:

Text shadow effect!

Example

h1 {
  text-shadow: 2px 2px red;
{}

Try it yourself

Lägg sedan till en suddig effekt till skuggan:

Text shadow effect!

Example

h1 {
  text-shadow: 2px 2px 5px red;
{}

Try it yourself

Följande exempel visar vit text med svarta skuggor:

Text shadow effect!

Example

h1 {
  color: white;
  text-shadow: 2px 2px 4px #000000;
{}

Try it yourself

Följande exempel visar neonbelysningsskuggor i rött:

Text shadow effect!

Example

h1 {
  text-shadow: 0 0 3px #FF0000;
{}

Try it yourself

Flera skuggor

För att lägga till flera skuggor i texten, kan du lägga till en kommateckenskilad lista av skuggor.

Följande exempel visar neonbelysningsskuggor i rött och blått:

Text shadow effect!

Example

h1 {
  text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
{}

Try it yourself

The following example shows white text with black, blue, and dark blue shadows:

Text shadow effect!

Example

h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
{}

Try it yourself

You can also use the text-shadow property to create a solid border (without shadow) around the text:

Border around the text!

Example

h1 {
  color: yellow;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
{}

Try it yourself