0

I am trying to add dashed border top on a div using css. I have this: https://jsfiddle.net/uexma4o6/74/

div {
    display: inline-block;
    width: 50px;
    height: 50px;
    border-top: 2px dashed #AAA;
}

The problem is that first and last dash are little longer than others. I think it's because actual borders on the left and right are included? How can I make all dashes same width? I am looking for solution without using border-image. Thanks.

Vikast
  • 745
  • 1
  • 6
  • 15

2 Answers2

0

You could use a SVG line within your div like -

<div>
    <svg width="50" height="2" viewBox="0 0 50 2" xmlns="http://www.w3.org/2000/svg">
        <line x1="0" y1="0" x2="50" y2="0" stroke-width="2" stroke="#AAA" stroke-dasharray="2" stroke-width="2"/>
    </svg>
</div>
brendangibson
  • 2,377
  • 2
  • 21
  • 36
0

Try this. you can adjust the size and width based on your requirement.

background-image: linear-gradient(to right, white 33%, rgba(255,255,255,0) 0%);
background-position: top;
background-size: 5px 3px;
background-repeat: repeat-x;
border-right-width: 2px;
Saravana
  • 3,389
  • 4
  • 21
  • 37