css - 有没有办法自定义 border 为 dashed 时的虚线间距?
巴扎黑
巴扎黑 2017-04-17 11:08:26
0
3
1626

CSS 的 border: 1px dashed 样式太难看了,虚线非常的宽,dotted 也是一样,间距太窄。

有没有办法控制虚线或者点的长度或者间距呢?

巴扎黑
巴扎黑

reply all(3)
PHPzhong

Displays a series of short square-ended dashes or line segments. The exact size and length of the segments are not defined by the specification and are implementation-specific.

——MDN

囧, it seems there is no solution. But you can use pictures as borders.

黄舟

No way.

But SVG lines can set the spacing.

path {
    stroke-dasharray: 4;
    stroke-dashoffset: 22;
}
PHPzhong

If you must do this, using a background image is also an option. Just cut a small piece to repeat, and the compatibility is very good. But if it is a vertical border, it is a little more troublesome.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template