文章详情页
css - 有没有办法自定义 border 为 dashed 时的虚线间距?
浏览:66日期:2023-08-03 18:23:53
问题描述
CSS 的 border: 1px dashed 样式太难看了,虚线非常的宽,dotted 也是一样,间距太窄。
有没有办法控制虚线或者点的长度或者间距呢?
问题解答
回答1: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
囧,看来没好办法。不过你可以用图片作边框用。
回答2:没有办法。
但SVG线条是可以设置间距的。
path { stroke-dasharray: 4; stroke-dashoffset: 22;}回答3:
如果一定要这样,使用一下背景图片也是个选择,切一小片repeat就好了,而且兼容性很好。但如果是竖边框的话,就稍微麻烦些。
标签:
CSS
相关文章:
排行榜
