stroke-width

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

stroke-width 表现属性定义了应用于图形的外轮廓的宽度。

你可以将此属性与以下 SVG 元素一起使用:

示例

html
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
  <!-- 默认外轮廓宽度为 1 -->
  <circle cx="5" cy="5" r="3" stroke="green" />

  <!-- 使用数值设置外轮廓宽度 -->
  <circle cx="15" cy="5" r="3" stroke="green" stroke-width="3" />

  <!-- 使用百分数设置外轮廓宽度 -->
  <circle cx="25" cy="5" r="3" stroke="green" stroke-width="2%" />
</svg>

使用说明

<length> | <percentage>
默认值 1px
动画性

备注: 百分数值始终以标准化 viewBox 的对角线长度的百分比计算。

规范

Specification
Scalable Vector Graphics (SVG) 2
# StrokeWidth

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
stroke-width

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support