美文网首页
2023.03.13 uniapp 实现 Button 水平垂

2023.03.13 uniapp 实现 Button 水平垂

作者: 薛定谔的猴子 | 来源:发表于2023-03-12 17:54 被阅读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>

相关文章

网友评论

      本文标题:2023.03.13 uniapp 实现 Button 水平垂

      本文链接:https://www.haomeiwen.com/subject/dckqrdtx.html