I'm trying to do a zig zag border on a button. I have googled one solution, but the zig zag border in this solution is at the bottom, but I needed it at the right side.
I was trying to rewrite the solution, but unfortunately the linear gradient is too hard for me. I was only able to create weird shapes.
Can you, please, help me to rewrite the solution to be on the right?
My CSS:
-webkit-mask-image: linear-gradient(0deg, transparent 30px, white 30px), linear-gradient(-135deg, white 15px, transparent 15px), linear-gradient(135deg, white 15px, transparent 15px);
-webkit-mask-position: left bottom;
-webkit-mask-repeat: repeat-x;
-webkit-mask-size: 100% 100%, 30px 30px, 30px 30px;
You would just have to change the gradient's angles, its size, position and repeat settings like in below snippet. The changes are self explanatory and so I am not detailing them much (leave me a comment if you need more explanation).
The other change that I've done is to remove the
outline
and move the dotted border to a pseudo. I have done this because masks work only till the border of the element and not theoutline
, so when the mask is applied, the outline will also get masked out.(The below snippet uses masks and so will not work in non-Webkit browsers, the second one would).
Using Background instead of Masks:
Masks have poor browser support and work only on WebKit powered browsers. To produce a cross-browser output, we could use
background-image
instead ofmask-image
.i would go, at this time, just with the gradient drawn from a pseudo, so it can be avalaible also for a few other browser. for old browsers , you'll see the dooted border all around.