Questions tagged [stroke-dasharray]

The SVG stroke-dasharray attribute controls the pattern of dashes and gaps used to stroke paths.

The stroke-dasharray attribute controls the pattern of dashes and gaps used to stroke paths.

As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet

It's a list of comma and/or white space separated s and s that specify the lengths of alternating dashes and gaps. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus, 5,3,2 is equivalent to 5,3,2,5,3,2. Example

Source code Output result

<line stroke-dasharray="5, 5"              x1="10" y1="10" x2="190" y2="10" />
<line stroke-dasharray="5, 10"             x1="10" y1="30" x2="190" y2="30" />
<line stroke-dasharray="10, 5"             x1="10" y1="50" x2="190" y2="50" />
<line stroke-dasharray="5, 1"              x1="10" y1="70" x2="190" y2="70" />
<line stroke-dasharray="1, 5"              x1="10" y1="90" x2="190" y2="90" />
<line stroke-dasharray="0.9"               x1="10" y1="110" x2="190" y2="110" />
<line stroke-dasharray="15, 10, 5"         x1="10" y1="130" x2="190" y2="130" />
<line stroke-dasharray="15, 10, 5, 10"     x1="10" y1="150" x2="190" y2="150" />
<line stroke-dasharray="15, 10, 5, 10, 15" x1="10" y1="170" x2="190" y2="170" />
<line stroke-dasharray="5, 5, 1, 5"        x1="10" y1="190" x2="190" y2="190" />

Source:

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray

66 questions
0
votes
1 answer

Issue with SVG path not animating as expected

I am using this video tutorial about inline SVGs as a reference. I am trying to replicate the effect of making an SVG line appear to draw itself in from its middle point out. The only difference between the approach from the video and mine is that…
0
votes
0 answers

Would does stroke-dashoffset glitch on Safari? Both mobile and Mac

I have an animation using an svg. You can see the site here: https://www.demo.simplerwebsites.com Codepen for just animation: https://codepen.io/webbchris2001/pen/wvojzwE The animation is meant to 'write the text'. It works fine on Firefox and…
0
votes
1 answer

(SVG - stroke-dsaharray) my path divides into two pathes when i start animation

I'm trying to animate SVG on scroll, i've created the SVG path my self using math, and it's showing as what i need exactly, but the problem started when i tried to add effect on path using CSS stroke-dasharray my problem is : the animation starts…
Burham B. Soliman
  • 1,380
  • 1
  • 9
  • 13
0
votes
0 answers

Line stroke CSS - limit the number of dashes

I'm trying to draw a limited dashed line with CSS, I mean that the number of dashes will be limited, For example, if the limit number will be 3 the line will be: _____ _____ _____ Currently, I'm using a percentage calculation to get the same result…
Ar26
  • 949
  • 1
  • 12
  • 29
0
votes
1 answer

display lines at required position using stroke-dasharray

I want to display 6 ticks at 0,20,40,60,80,100 from line x1="0" to x2="100" but last line is not display only first 5 are displayed. I am using the following code
gita 98
  • 53
  • 2
0
votes
0 answers

dynamically creating SVG circle with multiple segments using and -how to achieve animation?

I am trying create a SVG in Angular8. It should look circles facing each other. I created 2 circles with computed segments like this:
0
votes
1 answer

Animating and Controlling D3JS Collapsible Tree nodes and links

Additions to the solution given here -> is it possible to draw dashed links only for child to child nodes of tree layout in d3 js In the above example, I made some small changes in the CSS for Transition animation. Changes to CSS given…
Ahmed
  • 2,966
  • 7
  • 42
  • 69
0
votes
1 answer

Animate calligraphy using image-file instead of SVG

I am creating animated calligraphy using the stroke-dashoffset technique, applying the stroke as an animated mask on top of an SVG. This works on most browsers, but I would like to apply the same mask on top of a PNG instead. That way, even if the…
Ben Viatte
  • 485
  • 1
  • 5
  • 16
0
votes
1 answer

GSAP stroke animation strokeDashoffset not working properly

I'm working with gsap here I'm trying to do stroke animation I got it. but the problem is complete SVG is not coming half icon is coming I tried changing strokeDashoffset it might be an issue with the getTotalLength(); Can anyone help me out this…
Husna
  • 1,286
  • 4
  • 19
  • 48
0
votes
2 answers

How to create a responsive svg border animation

I want to create a border animation for a button element. The design is that the ends of the slanted rectangle are open and then close on hover. This is what we're trying to do (excuse my artistic "style"): Here's some code and a codepen example: a…
Adam
  • 47
  • 2
  • 9
0
votes
2 answers

How to animate my polygon using css stroke-dasharray?

I have a SVG that contains two polygons. I want to animate the first polygon from start to end and animate the second polygon after that. The animation will work like a fill. I want to use stroke-dasharray and css keyframes only. I am providing a…
0
votes
1 answer

Firefox svg stroke-dasharray with unit px

in chromium I can use stroke-dasharray followed by 2 numbers with the unit pixel, the same wont work in Firefox - it only accepts unit-less values. The Problem is that I cant strip off the unit from my variable. Do you have any ideas on how to get…
Teiem
  • 1,329
  • 15
  • 32
0
votes
0 answers

Svg circle with small stroke-dasharray missing antialiasing

If I use a very small stroke-dasharray on a circle, it produces strange "rectangle-like" shape in the middle of the circle. What causes this behavior and is there a way to solve it? Chrome stroke-dasharray:0.6 and lower fails Firefox…
Roland Soós
  • 3,125
  • 4
  • 36
  • 49
0
votes
1 answer

css reverse of animation

I did a css animation but I didn't animation-reverse. I tried variation version of the animation but I didn't. It has got some bug. .animation { stroke-dasharray: 296 0; stroke-dashoffset: 296; animation: geri-sayim 5s linear…
Orhan Gazi
  • 109
  • 1
  • 3
  • 10