uniapp - 键盘弹起背景图片不会被挤压

【释义】

uni.getSystemInfoSync()获取屏幕可用高度windowScreen做为背景图高度即可(非虚拟DOM也可以使用本思路).

 

【源码】

 

 1 <template>
 2     <view class="grace-margin">
 3         <input type="text" value="" placeholder="请输入!!!" style="margin-top: 300upx;border-bottom: 1upx solid #000;"/>
 4         <view class="grace-bg" :style="'height:'+screenHeight+'px !important;'"></view>
 5     </view>
 6 </template>
 7 <script>
 8     export default {
 9         data() {
10             return {
11                 screenHeight: ''
12             }
13         },
14         onLoad() {
15             this.screenHeight = uni.getSystemInfoSync().windowHeight;
16             console.log(uni.getSystemInfoSync());
17         },
18         methods: {}
19     }
20 </script>
21 <style scoped>
22     .grace-bg {
23         position: absolute;
24         filter: blur(5px);
25         z-index: -1;
26         background: url('https://uniapp-1257202511.cos.ap-chengdu.myqcloud.com/1558150500602.jpg') no-repeat;
27         top: 0;
28         left: 0;
29         right: 0;
30         bottom: 0;
31         background-size: cover;
32     }
33 </style>

 

转载于:https://www.cnblogs.com/cisum/p/10978316.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值