宽高比
@astryxdesign/core v0.7.1 · AspectRatio
Aspect Ratio Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
ratio | number | - | 宽除以高。16 / 9 是宽屏。写在 --astryx-aspect-ratio 上,不写成行内 aspect-ratio。 |
shape | 'rectangle' | 'ellipse' | 'rectangle' | 容器外形。两种外形都遵循 ratio。ellipse 且 ratio 为 1 时是正圆。 |
fit | 'cover' | 'contain' | 'center' | - | 子元素如何填满比例框。cover 裁切,contain 留边,center 保持原始尺寸。不传时子元素自己负责尺寸。 |
插槽
| 名称 | 说明 |
|---|---|
default | 放进比例框的内容。传了 fit 时只放一个子元素。 |
CSS 变量
| 名称 | 说明 |
|---|---|
--astryx-aspect-ratio | 宽高比。样式表可以覆盖这个变量,也可以直接覆盖 aspect-ratio。 |
原生属性
AspectRatio 的根元素是 <div>。
以下内容落到这个元素上:
- HTML 属性。
aria-*属性。data-*属性。class。style。
class 会合并。根元素同时写 data-shape。