paint-order CSS property lets you control the order in which the fill and stroke (and painting markers) of text content and shapes are drawn.

句法

/* Normal */
paint-order: normal;
/* Single values */
paint-order: stroke; /* draw the stroke first, then fill and markers */
paint-order: markers; /* draw the markers first, then fill and stroke */
/* Multiple values */
paint-order: stroke fill; /* draw the stroke first, then the fill, then the markers */
paint-order: markers stroke fill; /* draw markers, then stroke, then fill */
					

If no value is specified, the default paint order is fill , stroke , markers .

When one value is specified, that one is painted first, followed by the other two in their default order relative to one another. When two values are specified, they will be painted in the order they are specified in, followed by the unspecified one.

注意 : In the case of this property, markers are only appropriate when drawing SVG shapes involving the use of the marker-* properties (e.g. marker-start ) and <marker> element. They do not apply to HTML text, so in that case, you can only determine the order of stroke and fill .

normal

Paint the different items in normal paint order.

stroke ,
fill ,
markers

Specify some or all of these values in the order you want them to be painted in.

形式定义

初始值 normal
适用于 text elements
继承 yes
计算值 如指定
动画类型 discrete

形式句法

normal | [ fill || stroke || markers ]
					

范例

Reversing the paint order of stroke and fill

SVG

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
  <text x="10" y="75">stroke in front</text>
  <text x="10" y="150" class="stroke-behind">stroke behind</text>
</svg>
					

CSS

text {
  font-family: sans-serif;
  font-size: 50px;
  font-weight: bold;
  fill: black;
  stroke: red;
  stroke-width: 4px;
}
.stroke-behind {
  paint-order: stroke fill;
}
					

结果

规范

规范 状态 注释
Scalable Vector Graphics (SVG) 2
The definition of 'paint-order' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
paint-order Chrome 完整支持 35 Edge 完整支持 17 Firefox 完整支持 60 IE 不支持 No Opera 完整支持 22 Safari 完整支持 8 WebView Android 完整支持 37 Chrome Android 完整支持 35 Firefox Android 完整支持 60 Opera Android 完整支持 22 Safari iOS 完整支持 8 Samsung Internet Android 完整支持 3.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: