<style>

The SVG <style> element allows style sheets to be embedded directly within SVG content.

注意: SVG's style element has the same attributes as the corresponding element in HTML (see HTML's <style> element).

范例

<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
  <style>
    circle {
      fill: gold;
      stroke: maroon;
      stroke-width: 2px;
    }
  </style>
  <circle cx="5" cy="5" r="4" />
</svg>

					

属性

type

This attribute defines type of the style sheet language to use as a media type string. Value type <string> ; 默认值 : text/css ; Animatable : no

media

This attribute defines to which media the style applies. Value type <string> ; 默认值 : all ; Animatable : no

title

This attribute the title of the style sheet which can be used to switch between alternate style sheets. Value type <string> ; 默认值 : none ; Animatable : no

全局属性

Core Attributes

Most notably: id

Styling Attributes
class , style
Event Attributes

Global event attributes , Document element event attributes

用法注意事项

类别 None
准许内容 Any elements or character data

规范

规范
Scalable Vector Graphics (SVG) 1.1 (Second Edition) (SVG)
# StyleElement

浏览器兼容性

BCD tables only load in the browser

另请参阅

Found a problem with this page?

最后修改: , 由 MDN 贡献者