2023.03.13 uniapp 实现 Button 水平垂

2023-03-12  本文已影响0人  薛定谔的猴子

解决思路:

使用flex布局来实现button的水平垂直居中,并使用绝对定位来实现button的水平垂直居中

示例代码如下:
<template>
  <view class="container">
    <button type="default" class="center">我是按钮</button>
  </view>
</template>

<style>
.container {
  position: relative;
  height: 100%;
}
.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>
上一篇 下一篇

猜你喜欢

热点阅读