visibility

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.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

visibility属性让你能够控制一个图形元素的可见性。用了值hidden或者值collapse,当前的图形元素将不可见。

备注: 如果 <tspan><tref> 元素上的 visibility 属性设置为 hidden,则文本变得不可见,但是依然占用文本布局计算的空间。

根据属性 pointer-events 的值,图形元素如果属性 visibility 值设置为 hidden,依然能够响应事件。

作为一个表现属性,它可以直接用作 CSS 样式表内部的属性。请阅读 CSS visibility 以了解更多信息。

使用说明

类别 表现属性
visible | hidden | collapse | inherit
可变性 Yes

示例

元素

下列元素楞以使用visibility属性:

规范

Specification
CSS Display Module Level 3
# visibility
Scalable Vector Graphics (SVG) 2
# VisibilityControl

参见