uniapp 吸頂 小demo


<template>
	<view class="page-box">
		<uniStatusBar class="status"></uniStatusBar>
		<uniStatusBar></uniStatusBar>
		<view style="height:200px">滾動試試</view>
		<view class="box1" :style="{ top: statusBarHeight }">box1</view>
		<view class="box2">box2</view>
		<view style="height:200px"></view>
	</view>
</template>

<script>
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';//uniapp獲取手機狀態欄的高度
	export default {
		data() {
			return {
				statusBarHeight: statusBarHeight
			};
		},
	}
</script>

<style scoped>
	.page-box{
		height: 1000px;
	}
	.status{
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
		background: #FFFFFF;
	}
	.box1 {
	  position: -webkit-sticky;
	  position: sticky;
	  width: 100%;
	  height: 30px;
	  text-align: center;
	  color: #fff;
	  margin-bottom: 50px;
	  z-index: 1;
	  background: #007bff;
	}
	
	
	.box2 {
	  background: #f4516c;
	  width: 100%;
	  height: 30px;
	  text-align: center;
	}
</style>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM