CSS-tekstivarjo


Sisällysluettelo

    Näytä sisällysluettelo


Teksti varjo

Ominaisuus text-shadow lisää varjoa tekstiin.

Yksinkertaisimmassa käytössä määrität vain vaakavarjon (2px) ja pystyvarjon (2px):

Text shadow effect!

Esimerkki

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Lisää seuraavaksi väri (punainen) varjoon:

Text shadow effect!

Esimerkki

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px red;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Lisää sitten sumennustehoste (5px) varjoon:

Text shadow effect!

Esimerkki

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px 5px red;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>



Lisää tekstivarjoesimerkkejä

Esimerkki 1

Teksti-varjo valkoisella tekstillä:

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  color: white;
  text-shadow: 2px 2px 4px #000000;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Esimerkki 2

Teksti-varjo punaisella neonhehkulla:

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 0 0 3px #FF0000;
}
</style>
</head>
<body>

<h1>Text-shadow with red neon glow!</h1>

</body>
</html>


Esimerkki 3

Tekstivarjo punaisella ja sinisellä neonhehkulla:

h1 {
  text-shadow: 0 0 3px #ff0000, 0 0 5px #0000ff;
}

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}
</style>
</head>
<body>

<h1>Text-shadow with red and blue neon glow!</h1>

</body>
</html>


Esimerkki 4

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

Kokeile itse →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Vinkki: Siirry CSS-kirjasimet-luvullemme saadaksesi lisätietoja kirjasimien, tekstin koon ja tekstin tyylin muuttamisesta.

Vinkki: Siirry CSS-tekstitehosteita käsittelevään lukuomme saadaksesi lisätietoja erilaisista tekstitehosteista.




CSS-tekstin varjoominaisuus

text-shadow

Määrittää tekstiin lisätyn varjotehosteen