-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathAspectRatio.svx
81 lines (54 loc) · 1.3 KB
/
AspectRatio.svx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script>
import { AspectRatio, Tile } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";
</script>
The `AspectRatio` component is useful for constraining fluid content within an aspect ratio. To demo this, resize your browser for the examples below.
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
## Ratio 2x1
The default aspect ratio is `2x1`.
<AspectRatio>
2x1
</AspectRatio>
## Ratio 2x3
<AspectRatio ratio="2x3">
2x3
</AspectRatio>
## Ratio 16x9
<AspectRatio ratio="16x9">
16x9
</AspectRatio>
## Ratio 4x3
<AspectRatio ratio="4x3">
4x3
</AspectRatio>
## Ratio 1x1
<AspectRatio ratio="1x1">
1x1
</AspectRatio>
## Ratio 3x4
<AspectRatio ratio="3x4">
3x4
</AspectRatio>
## Ratio 3x2
<AspectRatio ratio="3x2">
3x2
</AspectRatio>
## Ratio 9x16
<AspectRatio ratio="9x16">
9x16
</AspectRatio>
## Ratio 1x2
<AspectRatio ratio="1x2">
1x2
</AspectRatio>
## Custom tag
By default, the `AspectRatio` component renders a `div` element. You can change this by specifying a `tag`.
<AspectRatio tag="h1" ratio="16x9">
Content
</AspectRatio>
## Tile (16x9)
<AspectRatio ratio="16x9">
<Tile style="position: absolute; height: 100%; width: 100%">
Content
</Tile>
</AspectRatio>