非常教程

SVG参考手册

属性 | Attributes

display(显示)

display属性使您可以控制图形或容器元素的渲染。

display="none"表示给定元素及其子元素不会被渲染。除none或inherit以外的任何值都表示给定的元素将由浏览器渲染。

应用于容器元素时,设置displaynone使容器及其所有子项不可见; 因此,它作用于一组元素。这意味着,设置有display="none"的元素的任何子元素都不会被渲染,即使他们的display属性有一个none以外的值。

display属性设置为none时,给定的元素不会成为渲染树的一部分。它影响<tspan><tref><altglyph>元素,事件处理过程,边框计算和剪切路径的计算:

  • 如果在<tspan><tref><altglyph>元素中将display设置为none,则为了文本布局的目的,文本字符串将被忽略。
  • 关于事件,如果display设置为none,则该元素不会收到事件。
  • display设置为none的图形元素的几何不包含在边界框和剪切路径计算中。

display属性只影响给定元素的直接渲染,而不会阻止元素被其他元素引用。例如,在<path>元素上设置display:none 会阻止该元素直接渲染到画布上,但<path>元素仍然可以被<textpath>元素引用; 此外,即使<path>设置了display: none,其几何图形也将用于文本路径处理。

display属性还会影响到屏幕外的画布上的直接渲染,例如使用蒙版或剪辑路径。因此,为<mask>元素的子元素设置display: none将防止给定的子元素作为掩码的一部分被渲染。类似地,为<clippath>元素

的子元素设置display: none将防止给定的子元素对裁剪路径产生影响。

作为一个表现属性,它也可以直接在CSS样式表中作为属性使用; 查看css display的更多信息。

用法上下文

Categories

Presentation attribute

Value

inline | block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit

Animatable

Yes

Normative document

SVG 1.1 (2nd Edition)

实例

适用元素

以下元素可以使用该display属性:

  • Graphics elements »
  • 文本内容元素»
  • <svg>
  • <g>
  • <switch>
  • <a>
  • <foreignobject>

属性 | Attributes相关

1.accent-height(焦点高度)
2.accumulate(积累)
3.additive
4.alignment-baseline(对齐基线)
5.ascent
6.attributename(属性名字)
7.Attributes(属性)
8.attributetype(属性类型)
9.azimuth(方位)
10.basefrequency
11.baseline-shift(基线漂移)
12.baseprofile
13.begin(开始)
14.bias(偏压)
15.calcmode
16.class
17.clip(剪辑)
18.clip-path(剪辑路径)
19.clip-rule(剪辑规则)
20.clippathunits
21.color(颜色)
22.color-interpolation(彩色插值)
23.color-interpolation-filters(色彩插值滤波器)
24.color-profile(彩色轮廓)
25.color-rendering(显色)
26.contentscripttype
27.contentstyletype
28.cursor(光标)
29.cx
30.cy
31.d
32.diffuseconstant
33.direction(方向)
34.divisor
35.dominant-baseline(显性基线)
36.dur
37.dx
38.dy
39.edgemode
40.elevation
41.end
42.externalresourcesrequired
43.fill
44.fill-opacity
45.fill-rule
46.filter
47.filterres
48.filterunits
49.flood-color
50.flood-opacity
51.font-family
52.font-size
53.font-size-adjust
54.font-stretch
55.font-style
56.font-variant
57.font-weight
58.fr
59.from
60.fx
61.fy
62.gradienttransform
63.gradientunits
64.height
65.href
66.image-rendering
67.in
68.in2
69.k1
70.k2
71.k3
72.k4
73.kernelmatrix
74.kernelunitlength
75.kerning
76.keysplines
77.keytimes
78.lengthadjust
79.letter-spacing
80.lighting-color
81.limitingconeangle
82.local
83.marker-end
84.marker-mid
85.marker-start
86.markerheight
87.markerunits
88.markerwidth
89.mask
90.maskcontentunits
91.maskunits
92.max
93.min
94.mode
95.numoctaves
96.opacity
97.operator
98.order
99.overflow
100.overline-position
SVG

可缩放矢量图形是基于可扩展标记语言(标准通用标记语言的子集),用于描述二维矢量图形的一种图形格式。它由万维网联盟制定,是一个开放标准。