CSS3
November 18, 2020

⑨ Эффекты тени при наведении

Продолжим изучение темы CSS3 - оформление текста. Если пропустили прошлые статьи, то вот ссылки на них:


📹 ГИФ 1. НАДПИСЬ С ТЕНЬЮ ПРИ НАВЕДЕНИИ
HTML
<h1>
  <span>Н</span><span>А</span><span>В</span><span>Е</span><span>Д</span><span>И</span><span>&nbsp;</span><span>Н</span><span>А</span><span>&nbsp;</span><span>М</span><span>Е</span><span>Н</span><span>Я</span>
</h1>
CSS
@import url('https://fonts.googleapis.com/css?family=Prosto+One');
body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: beige
}
h1 {
  font-family: 'Prosto One', cursive;
  font-size: 3em;
}
h1 span { 
  display: inline-block;
}
body:hover span { 
  animation: bounce .6s; 
}
@keyframes bounce {
  0%, 100% { 
    transform: translate(0); 
  }
  25% { 
    transform: rotateX(20deg) translateY(2px) rotate(-3deg); 
  }
  50% { 
    transform: translateY(-20px) rotate(3deg) scale(1.1);  
  }
}
span:nth-child(4n) { 
  color: hsl(50, 75%, 55%); 
  text-shadow: 1px 1px hsl(50, 75%, 45%), 2px 2px hsl(50, 45%, 45%), 3px 3px hsl(50, 45%, 45%), 4px 4px hsl(50, 75%, 45%); 
}
span:nth-child(4n-1) { 
  color: hsl(135, 35%, 55%); 
  text-shadow: 1px 1px hsl(135, 35%, 45%), 2px 2px hsl(135, 35%, 45%), 3px 3px hsl(135, 35%, 45%), 4px 4px hsl(135, 35%, 45%); 
}
span:nth-child(4n-2) { 
  color: hsl(155, 35%, 60%); 
  text-shadow: 1px 1px hsl(155, 25%, 50%), 2px 2px hsl(155, 25%, 50%), 3px 3px hsl(155, 25%, 50%), 4px 4px hsl(140, 25%, 50%); 
}
span:nth-child(4n-3) { 
  color: hsl(30, 65%, 60%); 
  text-shadow: 1px 1px hsl(30, 45%, 50%), 2px 2px hsl(30, 45%, 50%), 3px 3px hsl(30, 45%, 50%), 4px 4px hsl(30, 45%, 50%); 
}
h1 span:nth-child(2){ animation-delay:.05s; }
h1 span:nth-child(3){ animation-delay:.1s; }
h1 span:nth-child(4){ animation-delay:.15s; }
h1 span:nth-child(5){ animation-delay:.2s; }
h1 span:nth-child(6){ animation-delay:.25s; }
h1 span:nth-child(7){ animation-delay:.3s; }
h1 span:nth-child(8){ animation-delay:.35s; }
h1 span:nth-child(9){ animation-delay:.4s; }
h1 span:nth-child(10){ animation-delay:.45s; }
h1 span:nth-child(11){ animation-delay:.5s; }
h1 span:nth-child(12){ animation-delay:.55s; }
h1 span:nth-child(13){ animation-delay:.6s; }
h1 span:nth-child(14){ animation-delay:.65s; }

📹 ГИФ 2. СЕРДЦЕ С ТЕНЬЮ ПРИ НАВЕДЕНИИ
HTML
<span>&#10084;</span>
CSS
body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #FFDAF9;
  perspective: 800px;
}
span {
  font-weight: bold;
  font-size: 12em;
  color: #f5f5f5;
  transform: rotateX(35deg) rotateZ(1deg);
  text-shadow: white 0.006em 0.006em 0.007em, #9c9c9c 1px 1px 1px, #9c9c9c 1px 2px 1px, #9c9c9c 1px 3px 1px, #9c9c9c 1px 4px 1px, #9c9c9c 1px 5px 1px, #9c9c9c 1px 6px 1px, #9c9c9c 1px 7px 1px, #9c9c9c 1px 8px 1px, #9c9c9c 1px 9px 1px, #9c9c9c 1px 10px 1px, #9c9c9c 1px 11px 1px, #9c9c9c 1px 12px 1px, rgba(16, 16, 16, 0.4) 1px 18px 6px, rgba(16, 16, 16, 0.2) 1px 22px 10px, rgba(16, 16, 16, 0.2) 1px 26px 35px, rgba(16, 16, 16, 0.4) 1px 30px 65px, white -0.15em -0.1em 100px;
  transition: .3s linear;
}
span:hover {
  margin-top: -20px;
  text-shadow: white 0.006em 0.006em 0.007em, #9c9c9c 1px 1px 1px, #9c9c9c 1px 2px 1px, #9c9c9c 1px 3px 1px, #9c9c9c 1px 4px 1px, #9c9c9c 1px 5px 1px, #9c9c9c 1px 6px 1px, #9c9c9c 1px 7px 1px, #9c9c9c 1px 8px 1px, #9c9c9c 1px 9px 1px, #9c9c9c 1px 10px 1px, #9c9c9c 1px 11px 1px, #9c9c9c 1px 12px 1px, rgba(16, 16, 16, 0.4) 1px 38px 26px, rgba(16, 16, 16, 0.2) 1px 42px 30px, rgba(16, 16, 16, 0.2) 1px 46px 65px, rgba(16, 16, 16, 0.4) 1px 50px 95px, white -0.15em -0.1em 100px;
}

Продолжение в следующей статье!