This trick works for both horizontal and vertical borders:

/*Horizontal*/
background-image: linear-gradient(to right, black 33%, rgba(255,255,255,0) 0%);
background-position: bottom;
background-size: 3px 1px;
background-repeat: repeat-x;

/*Vertical*/
background-image: linear-gradient(black 33%, rgba(255,255,255,0) 0%);
background-position: right;
background-size: 1px 3px;
background-repeat: repeat-y;

You can adjust the size with background-size and the proportion with the linear-gradient percentages. In this example I have a dotted line of 1px dots and 2px spacing. This way you can have multiple dotted borders too using multiple backgrounds.

Try it in this JSFiddle or take a look at the code snippet example:

div {
  padding: 10px 50px;
}
.dotted {
  border-top: 1px #333 dotted;
}
.dotted-gradient {
  background-image: linear-gradient(to right, #333 40%, rgba(255, 255, 255, 0) 20%);
  background-position: top;
  background-size: 3px 1px;
  background-repeat: repeat-x;
}
.dotted-spaced {
  background-image: linear-gradient(to right, #333 10%, rgba(255, 255, 255, 0) 0%);
  background-position: top;
  background-size: 10px 1px;
  background-repeat: repeat-x;
}
.left {
  float: left;
  padding: 40px 10px;
  background-color: #F0F0DA;
}
.left.dotted {
  border-left: 1px #333 dotted;
  border-top: none;
}
.left.dotted-gradient {
  background-image: linear-gradient(to bottom, #333 40%, rgba(255, 255, 255, 0) 20%);
  background-position: left;
  background-size: 1px 3px;
  background-repeat: repeat-y;
}
.left.dotted-spaced {
  background-image: linear-gradient(to bottom, #333 10%, rgba(255, 255, 255, 0) 0%);
  background-position: left;
  background-size: 1px 10px;
  background-repeat: repeat-y;
}
<div>no
  <br>border</div>
<div class='dotted'>dotted
  <br>border</div>
<div class='dotted-gradient'>dotted
  <br>with gradient</div>
<div class='dotted-spaced'>dotted
  <br>spaced</div>

<div class='left'>no
  <br>border</div>
<div class='dotted left'>dotted
  <br>border</div>
<div class='dotted-gradient left'>dotted
  <br>with gradient</div>
<div class='dotted-spaced left'>dotted
  <br>spaced</div>

css border设置虚线样式? - html中文网

https://www.html.cn/qa/css3/13731.html

2019年11月7日 ... 在CSS中,可以通过设置border属性的值为dashed或dotted来设置虚线样式。 border属性可以用于设置边框的宽度、颜色、圆角度、样式(实线、 ...

CSS Borders

https://www.w3schools.com/css/css_border.asp

The CSS border properties allow you to specify the style, width, and color of an ... dotted - Defines a dotted border; dashed - Defines a dashed border; solid ...

CSS Border(边框) | 菜鸟教程

https://www.runoob.com/css/css-border.html

dashed: 定义一个虚线边框 ... border-color属性用于设置边框的颜色。 ... border- color, 简写属性,设置元素的所有边框中可见部分的颜色,或为4 个边分别设置颜色  ...

table中如何设置内部边框为虚线-CSDN论坛

https://bbs.csdn.net/topics/340049081

为了对html不同标签加边框虚线,我们选择几个常用标签对齐设置边框虚线效果。 1、html常用标签p标签span ul li table tr td 2、实例用到CSS属性单词border width  ...

border-style - CSS: Cascading Style Sheets | MDN

https://developer.mozilla.org/en-US/docs/Web/CSS/border-style

Jan 15, 2021 ... The border-style shorthand CSS property sets the line style for all four sides of an element's border. ... border-style: dashed groove none dotted; ... HTML. <table> < tr> <td class="b1">none</td> <td class="b2">hidden</td> <td ...

html表格虚线边框 - 搜狗搜索

https://z.sogou.com/web/searchList.jsp?keyword=html%E8%A1%A8%E6%A0%BC%E8%99%9A%E7%BA%BF%E8%BE%B9%E6%A1%86&pid=sogou-waps-0e274e1d1a8948f1

2021年1月6日 ... html表格虚线边框- 约1968个回答- 搜狗知识 ... 在border属性中有很多的属性,第一... 5/10 ... css如何设置虚线边框?css设置虚线边框的方法示例- 知乎 · 1 - 在网页布局中 ,有时候为了 ... table中如何设置内部边框为虚线- CSDN论坛.

HTML中如何将表格最外层边框设置成实线,内单元格边框设置虚线 ...

https://blog.csdn.net/qq_45103133/article/details/104803705

2020年3月11日 ... 如图中所示,最外层边框为实线,内部单元格边框为虚线 以下为HTML部分的 一部分代码 <body> <form action=""> <table>/*设置表格代码*/ <th> ...

css如何设置虚线边框?css设置虚线边框的方法示例- 知乎

https://zhuanlan.zhihu.com/p/138481147

2020年5月6日 ... border中dotted跟dashed都是可以用来设置边框虚线的,只是dashed ... DOCTYPE html> <html> <head> <title></title> <style type="text/css"> ...

CSS border-style property

https://www.w3schools.com/cssref/pr_border-style.asp

... table-layout text-align text-align-last text-decoration text-decoration-color text- decoration-line text-decoration-style ... The border-style property sets the style of an element's four borders. ... top border is dotted; right border is solid; bottom border is double; left border is dashed ... HTML DOM reference: borderStyle property.

How to increase space between dotted border dots - Stack Overflow

https://stackoverflow.com/questions/6250394/how-to-increase-space-between-dotted-border-dots

In this example I have a dotted line of 1px dots and 2px spacing. This way you can have ... And in the following, you create your border (here's an example with dots) hr:after ... The 50% of the background tag is how wide the dash actually is.

html+css画虚线,实线_zhuyu19911016520-CSDN博客_html实线

https://blog.csdn.net/zhuyu19911016520/article/details/37921877

2014年7月18日 ... 因此此前的任何border-color 和border-width 设置都会被清除。 在IE5.5+ 中,边框 属性可以直接应用于内联要素。而在此前的版本中,内联要素要 ...

html中加入虚线- Trible.H - 博客园

https://www.cnblogs.com/glj1203/archive/2011/11/23/2260434.html

2011年11月23日 ... 请参阅各参数对应的属性。 默认值为: medium none 。 border-color 的默认值将 采用文本颜色。 说明: 设置对象的边框样式。

How to draw border with dotted line - Microsoft Q&A

https://docs.microsoft.com/answers/questions/22807/how-to-draw-border-with-dotted-line.html

Apr 15, 2020 ... As far as I know, it's not possible to do it with <Border>. However, with a Rectangle, where you don't specify the Fill (thus, the Fill remains ...

How to draw a dotted line with css? - Stack Overflow

https://stackoverflow.com/questions/1746491/how-to-draw-a-dotted-line-with-css

Using HTML: <div class="horizontal_dotted_line"></div>. and in styles.css: . horizontal_dotted_line{ border-bottom: 1px dotted [color]; width: [put ...

border | CSS-Tricks

https://css-tricks.com/almanac/properties/b/border/

Apr 11, 2018 ... dashed : A line that consists of dashes. dotted : A line that consists of dots. double : Two lines are drawn around the element. groove : ...

Set Line Style for Table Borders in PowerPoint 2013 for Windows

https://www.indezine.com/products/powerpoint/learn/tables/2013/set-line-style-for-tables-borders-ppt.html

Jun 12, 2014 ... And you can also make table borders sport dashed or dotted lines instead of simple thin lines: Change the Line Style of Existing Table Borders:.

Control the dashed border stroke length and distance between ...

https://stackoverflow.com/questions/2771171/control-the-dashed-border-stroke-length-and-distance-between-strokes

Reference: http://www.w3.org/TR/CSS2/box.html#border-style-properties ... We can create the dashed border by using a path or a polygon element and setting ...

CSS Trick – Customized Dashed or Dotted Border

https://kovart.github.io/dashed-border-generator/

The SVG features give us the ability to change the distance between dashed lines, set custom pattern, add dash offset or even change a line cap. Generated SVG ...