|
1 |
| -# Aspect |
2 |
| - |
3 |
| -> The `<b-aspect>` component can be used to maintain a minimum responsive aspect ratio for content. |
4 |
| -> When the content is longer than the available height, then the component will expand vertically to |
5 |
| -> fit all content. If the content is shorter than the computed aspect height, the component will |
6 |
| -> ensure a minimum height is maintained. |
7 |
| -
|
8 |
| -## Overview |
9 |
| - |
10 |
| -The default [aspect](<https://en.wikipedia.org/wiki/Aspect_ratio_(image)>) ratio is `1:1` (ratio of |
11 |
| -`1`), which makes the height always be at least the same as the width. The `aspect` prop can be used |
12 |
| -to specify an arbitrary aspect ratio (i.e. `1.5`) or a ratio as a string such as `'16:9'` or |
13 |
| -`'4:3'`. |
14 |
| - |
15 |
| -The width will always be 100% of the available width in the parent element/component. |
16 |
| - |
17 |
| -```html |
18 |
| -<template> |
19 |
| - <div> |
20 |
| - <b-form-group label="Aspect ratio" label-for="ratio" label-cols-md="auto" class="mb-3"> |
21 |
| - <b-form-select id="ratio" v-model="aspect" :options="aspects"></b-form-select> |
22 |
| - </b-form-group> |
23 |
| - <b-card> |
24 |
| - <b-aspect :aspect="aspect"> |
25 |
| - This will always be an aspect of "{{ aspect }}", |
26 |
| - except when the content is too tall. |
27 |
| - </b-aspect> |
28 |
| - </b-card> |
29 |
| - </div> |
30 |
| -</template> |
31 |
| - |
32 |
| -<script> |
33 |
| - export default { |
34 |
| - data() { |
35 |
| - return { |
36 |
| - aspect: '16:9', |
37 |
| - aspects: [ |
38 |
| - { text: '4:3 (SD)', value: '4:3' }, |
39 |
| - { text: '1:1 (Square)', value: '1:1' }, |
40 |
| - { text: '16:9 (HD)', value: '16:9' }, |
41 |
| - { text: '1.85:1 (Widescreen)', value: '1.85:1' }, |
42 |
| - { text: '2:1 (Univisium/Superscope)', value: '2:1' }, |
43 |
| - { text: '21:9 (Anamorphic)', value: '21:9' }, |
44 |
| - { text: '1.43:1 (IMAX)', value: '1.43:1' }, |
45 |
| - { text: '3:2 (35mm Film)', value: '3:2' }, |
46 |
| - { text: '3:1 (APS-P)', value: '3:1' }, |
47 |
| - { text: '4/3 (Same as 4:3)', value: 4 / 3 }, |
48 |
| - { text: '16/9 (Same as 16:9)', value: 16 / 9 }, |
49 |
| - { text: '3 (Same as 3:1)', value: 3 }, |
50 |
| - { text: '2 (Same as 2:1)', value: 2 }, |
51 |
| - { text: '1.85 (Same as 1.85:1)', value: 1.85 }, |
52 |
| - { text: '1.5', value: 1.5 }, |
53 |
| - { text: '1 (Same as 1:1)', value: 1 } |
54 |
| - ] |
55 |
| - } |
56 |
| - } |
57 |
| - } |
58 |
| -</script> |
59 |
| - |
60 |
| -<!-- b-aspect.vue --> |
61 |
| -``` |
62 |
| - |
63 |
| -## See also |
64 |
| - |
65 |
| -- [`<b-embed>` component](/docs/components/embed) for responsive embeds (videos, iframes, etc) |
| 1 | +# Aspect |
| 2 | + |
| 3 | +> The `<b-aspect>` component can be used to maintain a minimum responsive aspect ratio for content. |
| 4 | +> When the content is longer than the available height, then the component will expand vertically to |
| 5 | +> fit all content. If the content is shorter than the computed aspect height, the component will |
| 6 | +> ensure a minimum height is maintained. |
| 7 | +
|
| 8 | +## Overview |
| 9 | + |
| 10 | +The default [aspect](<https://en.wikipedia.org/wiki/Aspect_ratio_(image)>) ratio is `1:1` (ratio of |
| 11 | +`1`), which makes the height always be at least the same as the width. The `aspect` prop can be used |
| 12 | +to specify an arbitrary aspect ratio (i.e. `1.5`) or a ratio as a string such as `'16:9'` or |
| 13 | +`'4:3'`. |
| 14 | + |
| 15 | +The width will always be 100% of the available width in the parent element/component. |
| 16 | + |
| 17 | +```html |
| 18 | +<template> |
| 19 | + <div> |
| 20 | + <b-form-group label="Aspect ratio" label-for="ratio" label-cols-md="auto" class="mb-3"> |
| 21 | + <b-form-select id="ratio" v-model="aspect" :options="aspects"></b-form-select> |
| 22 | + </b-form-group> |
| 23 | + <b-card> |
| 24 | + <b-aspect :aspect="aspect"> |
| 25 | + This will always be an aspect of "{{ aspect }}", |
| 26 | + except when the content is too tall. |
| 27 | + </b-aspect> |
| 28 | + </b-card> |
| 29 | + </div> |
| 30 | +</template> |
| 31 | + |
| 32 | +<script> |
| 33 | + export default { |
| 34 | + data() { |
| 35 | + return { |
| 36 | + aspect: '16:9', |
| 37 | + aspects: [ |
| 38 | + { text: '4:3 (SD)', value: '4:3' }, |
| 39 | + { text: '1:1 (Square)', value: '1:1' }, |
| 40 | + { text: '16:9 (HD)', value: '16:9' }, |
| 41 | + { text: '1.85:1 (Widescreen)', value: '1.85:1' }, |
| 42 | + { text: '2:1 (Univisium/Superscope)', value: '2:1' }, |
| 43 | + { text: '21:9 (Anamorphic)', value: '21:9' }, |
| 44 | + { text: '1.43:1 (IMAX)', value: '1.43:1' }, |
| 45 | + { text: '3:2 (35mm Film)', value: '3:2' }, |
| 46 | + { text: '3:1 (APS-P)', value: '3:1' }, |
| 47 | + { text: '4/3 (Same as 4:3)', value: 4 / 3 }, |
| 48 | + { text: '16/9 (Same as 16:9)', value: 16 / 9 }, |
| 49 | + { text: '3 (Same as 3:1)', value: 3 }, |
| 50 | + { text: '2 (Same as 2:1)', value: 2 }, |
| 51 | + { text: '1.85 (Same as 1.85:1)', value: 1.85 }, |
| 52 | + { text: '1.5', value: 1.5 }, |
| 53 | + { text: '1 (Same as 1:1)', value: 1 } |
| 54 | + ] |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | +</script> |
| 59 | + |
| 60 | +<!-- b-aspect.vue --> |
| 61 | +``` |
| 62 | + |
| 63 | +## See also |
| 64 | + |
| 65 | +- [`<b-embed>` component](/docs/components/embed) for responsive embeds (videos, iframes, etc) |
0 commit comments