<view class="search" >
<input placeholder="请输入要搜索的内容"></input>
</view>
.search{
width: 80vw;
height: 60rpx;
display: flex;
flex-direction: row;
border: 1px solid slategray;
border-radius: 40rpx;
padding-left: 50rpx;
align-items: center;
align-self:center;
}
<view class="flex-column"> <view class="search" > <input placeholder="请输入要搜索的内容"></input> </view> </view>
search 外层加个 view ,设置样式
.flex-column{ display: flex; flex-direction: column }
.tongyi{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-top: 20rpx;
}
justify-content: center;
容器search也就80vw,input宽度占100%,事实上是已经居中,只是容器没居中
width: 80vw; height: 60rpx; display: flex; flex-direction: row; border: 1px solid slategray; border-radius: 40rpx; padding-left: 50rpx; justify-content: center; // 垂直居中 align-items: center; // 水平居中
若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人
https://developers.weixin.qq.com/s/w0Xui8mR7Shg