【css】小程序 实现view始终跟随页面变化显示在最底部

【css】微信小程序/支付宝小程序 实现view始终跟随页面变化显示在最底部

需求:在小程序开发过程中,通常需要在首页或者重要的页面底部加上技术支持等字语。那么如何在[页面内容小于页面高度时]、[页面内容大于页面高度时]显示该字语在页面底部呢?

实现效果的重点样式

// 这是技术支持等字语外边的盒子,这三个属性很重要
.main .main-content{
  position: relative;
  min-height: 100vh;
  box-sizing: border-box;
}
// 这是技术支持等字语重要样式
.main-content .content-bottom{
  position: absolute;
  bottom: 0;
}

注意点:一定一定是包着‘技术支持’的大盒子样式里设置上边三个属性。

好啦~下面上代码、效果图…

// wxml
<view class="main">
	<view class="main-content">
		<view class="content-box" wx:for="{{couponList}}" wx:key="index">
			<text>{{item.title}}</text>
			<text>{{item.content}}</text>
		</view>
		<view class="content-bottom">古夋科技</view>
	</view>
</view>
//  wxss
page{
  background: #f5f5f5;
}
//技术支持等字语外边的盒子【重要】
.main .main-content{
  position: relative;
  min-height: 100vh;
  box-sizing: border-box;
  padding-bottom: 60rpx;
  padding-top: 30rpx;
}
.main-content .content-box {
  height: 250rpx;
  width: 90%;
  margin: 0 auto 30rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 20rpx;
  color: #38b5f8;
}
//技术支持等字语样式【重要】
.main-content .content-bottom{
  width: 100%;
  height: 60rpx;
  text-align: center;
  letter-spacing: 4rpx;
  position: absolute;
  bottom: 0;
}

效果图

在这里插入图片描述

  • 6
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值