Skip to main content

transform-center

插件名#

- name: transform-center- aliases: center

安装#

npm install @jswork/styled-plugin-transform-center

参数#

名称类型description
valuestring居中方式; x/y/xy; 默认为 'xy'

绝对居中的一种实现方式。

原理#

  1. 父级 position: relative;
  2. 当前元素 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 ()
            ^