在微信小程序开发过程中,我们一般会在页面的下方固定一个悬浮。那么下面就简单讲解下如何具体的实现。先上下效果图,这边可以看到下方有个固定的悬浮按钮。
<view class="consultBtn">
<t-icon name="chat" class="icon"/>
<view class="tip">在线咨询</view>
</view>
.consultBtn {
position: fixed;
width: 200rpx;
height: 50rpx;
bottom: 120rpx;
left: 26rpx;
background-color: rgba(2, 2, 2, 0.4);
border-radius: 30rpx;
line-height: 50rpx;
display: flex;
justify-content: center;
}
.consultBtn .tip{
color: white;
font-size: 26rpx;
font-weight: lighter;
}
.consultBtn .icon {
padding: 10rpx 6rpx;
color: white;
}
在CSS中运用background-color: rgba(2, 2, 2, 0.4);使得盒子背景半透明.
background-color:rgba(0,0,0,0~1