Alex Rivera | Logout

SVG/CSS stroke dashed line with two colors - is it possible?

Asked 2012-09-25T00:37:31.030
24

Is it possible to use CSS to define a line (or shape edge) with two alternating colors that are dashed? That is, if 1 and 2 are different colored pixels, then

1212121212121212 or 112211221122

I basically want some way to use stroke-dasharray with two colors. The line itself is completely colored.

If this is not possible, what is a good way to approximate it? For example, I could create a repeated linear gradient with two colors alternating, but this would be hard to set the two colors from javascript.

Edit
Report

1 Answer

-3

For a border that has 50 dashes along the bottom, create 50 divs with increasing margin-left, and an overall container with overflow:hidden.

answered 2012-09-30T00:28:57.843

Your Answer