transform-center
插件名#
- name: transform-center- aliases: center安装#
- npm
- Yarn
npm install @jswork/styled-plugin-transform-centeryarn add @jswork/styled-plugin-transform-center参数#
| 名称 | 类型 | description |
|---|---|---|
| value | string | 居中方式; x/y/xy; 默认为 'xy' |
绝对居中的一种实现方式。
原理#
- 父级 position: relative;
- 当前元素 top:50%; transform:translateY(-50%);
用法#
<View debug wh={200} auto relative> <View bg="#f60" c="#fff" f="38" wh={100} lh={100} circle plugin="center:xy" tc> 道 </View></View>演示#
Live Editor
Result
SyntaxError: Unexpected token (1:8)
1 : return ()
^