search

Home  >  Q&A  >  body text

css - 有没有办法自定义 border 为 dashed 时的虚线间距?

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

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

巴扎黑巴扎黑2828 days ago1653

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 11:10:26

    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.

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:10:26

    No way.

    But SVG lines can set the spacing.

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

    reply
    0
  • PHPz

    PHPz2017-04-17 11:10:26

    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.

    reply
    0
  • Cancelreply