Advertisement
OrangePulp

CodePen Home Animated text fill with svg text practice

Feb 4th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.73 KB | None | 0 0
  1. /******************************************HTML****************************************/
  2. svg(viewBox="0 0 600 300")
  3.   // Symbol
  4.   symbol#s-text
  5.     text(text-anchor="middle", x="50%", y="50%", dy=".35em")
  6.       | dale
  7.   // Duplicate symbols
  8.   use.text(xlink:href="#s-text")
  9.   use.text(xlink:href="#s-text")
  10.   use.text(xlink:href="#s-text")
  11.   use.text(xlink:href="#s-text")
  12.   use.text(xlink:href="#s-text")
  13.  
  14.  
  15. /*************************************************************SCSS/CSS***************************************/
  16. $colors: #F2385A, #F5A503, #E9F1DF, #56D9CD, #3AA1BF;
  17. $max: length($colors);
  18. $dash: 70;
  19. $dash-gap: 10;
  20. $dash-space: $dash * ($max - 1) + $dash-gap * $max;
  21. $time: 6s;
  22. $time-step: $time/$max;
  23.  
  24. /* Main styles */
  25. @import url(https://fonts.googleapis.com/css?family=Open+Sans:800);
  26.  
  27. .text {
  28.   fill: none;
  29.   stroke-width: 3;
  30.   stroke-linejoin: round;
  31.   stroke-dasharray: $dash $dash-space;
  32.   stroke-dashoffset: 0;
  33.   -webkit-animation: stroke $time infinite linear;
  34.   animation: stroke $time infinite linear;
  35.  
  36.   @for $item from 1 through $max {
  37.     &:nth-child(#{$max}n + #{$item}) {
  38.      $color: nth($colors, $item);
  39.       stroke: $color;
  40.       -webkit-animation-delay: -($time-step * $item);
  41.       animation-delay: -($time-step * $item);
  42.     }
  43.   }
  44. }
  45.  
  46. @-webkit-keyframes stroke {
  47.   100% {
  48.     stroke-dashoffset: -($dash + $dash-gap) * $max;
  49.   }
  50. }
  51.  
  52. @keyframes stroke {
  53.   100% {
  54.     stroke-dashoffset: -($dash + $dash-gap) * $max;
  55.   }
  56. }
  57.  
  58. /* Other styles */
  59. html, body {
  60.   height: 100%;
  61. }
  62.  
  63. body {
  64.   background: #111;
  65.   background-size: .2em 100%;
  66.   font: 5em/1 Open Sans, Impact;
  67.   text-transform: uppercase;
  68.   margin: 0;
  69. }
  70.  
  71. svg {
  72.   position: absolute;
  73.   width: 100%;
  74.   height: 100%;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement