Skip to content

Commit 26b5463

Browse files
authored
Add more examples of invisible elements (#1818)
1 parent d09df7b commit 26b5463

1 file changed

Lines changed: 66 additions & 4 deletions

File tree

pages/examples/visible.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,36 @@ This `span` element is visible (by default, elements are visible).
1414

1515
## Hidden with CSS visibility
1616

17-
This `span` element is not visible because of the CSS`visibility` property.
17+
This `span` element is not visible because of the CSS `visibility` property.
1818

1919
```html
2020
<span style="visibility: hidden">I'm the invisible man</span>
2121
```
2222

2323
## Hidden with CSS display
2424

25-
This `span` element is not visible because of the CSS`display` property.
25+
This `span` element is not visible because of the CSS `display` property.
2626

2727
```html
2828
<span style="display: none">I'm the invisible man</span>
2929
```
3030

3131
## Hidden with CSS position
3232

33-
This `span` element is not visible because it is positioned off-screen
33+
These `span` elements are not visible because they are positioned off-screen. Note that depending on device size and actual position of the `span` elements, they might be visible on some larger device or long pages.
3434

3535
```html
3636
<span style="position: absolute; top: -9999px; left: -9999px;">Incredible how you can</span>
3737
```
3838

39+
```html
40+
<span style="position: absolute; top: -9999px">See right through me</span>
41+
```
42+
43+
```html
44+
<span style="position: absolute; left: -9999px;">When you hear a sound</span>
45+
```
46+
3947
## Hidden due to a lack of content
4048

4149
This `span` element is not visible because it contains only whitespace and line breaks.
@@ -47,12 +55,66 @@ This `span` element is not visible because it contains only whitespace and line
4755
</span>
4856
```
4957

58+
This `span` element is not visible because its text content has size 0.
59+
60+
```html
61+
<span style="font-size: 0px">That you just can't place</span>
62+
```
63+
5064
## Hidden due to matching colors
5165

5266
This `span` element is not visible because it has the exact same color as its background.
5367

5468
```html
55-
<span style="color: #00F; background: #00F;">See right through me</span>
69+
<span style="color: #00F; background: #00F;">Feel something move</span>
70+
```
71+
72+
## Hidden due to transparency
73+
74+
This `span` element is not visible because it has no opacity.
75+
76+
```html
77+
<span style="opacity: 0">That you just can't trace</span>
78+
```
79+
80+
This `span` element is not visible because it's text is fully transparent.
81+
82+
```html
83+
<span style="color: transparent">When something sits</span>
84+
```
85+
86+
## Hidden due to clipping
87+
88+
This `span` element is not visible because it's size is reduced to zero, and any overflow is hidden.
89+
90+
```html
91+
<span style="height: 0px; width: 0px; overflow: hidden">On the end of your bed</span>
92+
```
93+
94+
This `span` element is not visible because its content is fully indented out of it, and any overflow is hidden.
95+
96+
```html
97+
<span style="text-indent: -200%; overflow: hidden">Don't turn around</span>
98+
```
99+
100+
This `span` element is not visible because it is clipped to zero size.
101+
102+
```html
103+
<span style="clip-path: inset(50%)">When you hear me tread</span>
104+
```
105+
106+
## Hidden due to transformation
107+
108+
This `div` element is not visible because it is scaled to 0%.
109+
110+
```html
111+
<div style="transform: scale(0%)">I'm the invisible man</div>
112+
```
113+
114+
This `div` element is not visible because it is translated out of screen.
115+
116+
```html
117+
<div style="transform: translate(-100%)">I'm the invisible man</div>
56118
```
57119

58120
[visible]: /glossary/#visible

0 commit comments

Comments
 (0)