<h1>不使用 <pattern> </h1>
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<circle cx="10" cy="10" r="2" fill="black" />
<circle cx="30" cy="10" r="2" fill="black" />
<circle cx="50" cy="10" r="2" fill="black" />
<circle cx="70" cy="10" r="2" fill="black" />
<circle cx="90" cy="10" r="2" fill="black" />
<circle cx="10" cy="30" r="2" fill="black" />
<circle cx="30" cy="30" r="2" fill="black" />
<circle cx="50" cy="30" r="2" fill="black" />
<circle cx="70" cy="30" r="2" fill="black" />
<circle cx="90" cy="30" r="2" fill="black" />
<circle cx="10" cy="50" r="2" fill="black" />
<circle cx="30" cy="50" r="2" fill="black" />
<circle cx="50" cy="50" r="2" fill="black" />
<circle cx="70" cy="50" r="2" fill="black" />
<circle cx="90" cy="50" r="2" fill="black" />
<circle cx="10" cy="70" r="2" fill="black" />
<circle cx="30" cy="70" r="2" fill="black" />
<circle cx="50" cy="70" r="2" fill="black" />
<circle cx="70" cy="70" r="2" fill="black" />
<circle cx="90" cy="70" r="2" fill="black" />
<circle cx="10" cy="90" r="2" fill="black" />
<circle cx="30" cy="90" r="2" fill="black" />
<circle cx="50" cy="90" r="2" fill="black" />
<circle cx="70" cy="90" r="2" fill="black" />
<circle cx="90" cy="90" r="2" fill="black" />
</svg>
<h1>使用 <pattern> 实现</h1>
<!-- 此时代码看起来比上面那版要简洁多了 -->
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="dotPattern" width="20" height="20" patternUnits="userSpaceOnUse">
<circle cx="10" cy="10" r="2" fill="black" />
</pattern>
</defs>
<rect width="100" height="100" fill="url(#dotPattern)" />
</svg>
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
控制台