Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

What exactly the SVG property stroke-dashoffset means and what is the relationship between stroke-dasharray?

I really don't understand the relationship between stroke-dasharray and stroke-dashoffset, and why I set the stroke-dashoffset to 5 is difference when set to 100? set the stroke-dashoffset to 100 it will move longer and 5 will just move little shorter.Why?

stroke-dashoffset: 100

/* *************************** */
/* ******* @Keyframes ******** */
/* ******* @Keyframes ******** */
/* *************************** */
@keyframes offset{
  100%{
    stroke-dashoffset: 0;
  }
}



.logo{
  stroke:#2CB552;
  stroke-width:1.5px;
  stroke-dasharray: 5;
  stroke-dashoffset: 100;
  animation: offset 5s linear forwards;
}

stroke-dashoffset: 5

/* *************************** */
/* ******* @Keyframes ******** */
/* ******* @Keyframes ******** */
/* *************************** */
@keyframes offset{
  100%{
    stroke-dashoffset: 0;
  }
}



.logo{
  stroke:#2CB552;
  stroke-width:1.5px;
  stroke-dasharray: 5;
  stroke-dashoffset: 5;
  animation: offset 5s linear forwards;
}

1 Answer

Steven Parker
Steven Parker
231,271 Points

This question appears to be an exact duplicate of this other one. You can delete one of them (as long as it has no answers) by clicking on the little rectangle with the 3 dots to reveal the "Delete Question" option.