适配android和iOS上position:absolute和input问题

本文介绍了一种解决iOS和Android平台上absolute布局与input元素兼容性问题的方法。通过JavaScript动态调整页面底部布局的显示状态,确保在不同设备和操作系统上的正常显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//适配android上absolute和input的问题var oHeight = $(document).height(); //屏幕当前的高度$(window).resize(function() {
if($(document).height() < oHeight -100) {
$(".bottombox").css("display", "none");
} else {
$(".bottombox").css("display", "block");
}
});
//适配iOS上absolute和input的问题
触发焦点和失去焦点的时候调用一下方法
function textareadiscus(){
$(".bottombox").css("display", "block");
}
function textfoucs(){
$(".bottombox").css("display", "none");
}

转载于:https://www.cnblogs.com/tian-sun/p/7404346.html

<template> <!-- <view class="modal-overlay" @tap.stop="hideModal" v-if="visible" @touchmove.stop.prevent> --> <view class="modal-overlay" @tap.stop="hideModal" @touchmove.stop.prevent> <view class="modal-content"> <swiper class="swiper" :class="advData.value.length==1?'on':''" :autoplay="autoplay" :duration="duration" @change="stopChange" v-if="advData.type == 'pic' && advData.value.length"> <swiper-item v-for="(item,index) in advData.value" :key="index" @click="jump(item.link)"> <!-- <view class="swiper-item"> --> <view class="swiper-item-img"> <image :src="item.img" mode="aspectFit"></image> </view> <!-- </view> --> </swiper-item> </swiper> <text class="iconfont icon-ic_close1 fs-40 text--w111-fff"></text> </view> </view> </template> <style scoped> .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.6); display: flex; height: 100%; justify-content: center; align-items: center; z-index: 1000; -webkit-overflow-scrolling: touch; /* 禁用 iOS 弹性滚动 */ } .modal-content { background-size: contain; background-repeat: no-repeat; position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%); height: 50%; z-index: 1001; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; } .modal-content-mobile { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 30%; background-size: cover; background-position: center; z-index: 1001; } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10rpx; } .modal-footer1 { position: relative; top: 32%; transform: translate(-50%, -50%); margin-left: 48%; align-items: center; } .modal-footer2 { position: relative; top: 28%; margin-left: 50%; transform: translate(-50%, -50%); align-items: center; } .modal-footer3 { position: relative; top: 55%; margin-left: 50%; transform: translate(-50%, -50%); align-items: center; } .modal-body { font-size: 25rpx; position: relative; margin: 0 auto; top: 19%; width: 75%; align-items: center; } .modal-body-mobile { font-size: 35rpx; position: relative; margin: 0 auto; top: 35%; width: 80%; align-items: center; } .modal-body view { margin-top: 5%; justify-content: center; align-items: center; } .modal-body-mobile view { margin-top: 5%; justify-content: center; align-items: center; } input { justify-content: center; margin-top: 3%; width: 80%; background: #FFFFFF; border-radius: 8px 8px 8px 8px; padding: 14rpx 32rpx; font-size: 30rpx; } .swiper-item { height: 100%; text-align: center; position: relative; display: flex; align-items: flex-end; flex-direction: column-reverse } .jump-over { position: absolute; height: 325rpx; text-align: center; padding: 0 15rpx; font-weight: bold; z-index: 999; bottom: 20rpx; top: 50%; left: 50%; transform: translate(-50%, -50%); } .jump_img { position: absolute; bottom: 80rpx; left: 50%; transform: translateX(-50%); z-index: 1002; } .swiper-item { height: 100%; text-align: center; position: relative; display: flex; align-items: flex-end; flex-direction: column-reverse } .swiper-item-img { width: 60%; max-width: 800px; margin: 0 auto; height: 100%; position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; } .swiper-item-img image { width: 100%; height: 100%; object-fit: contain; } .modal-content { /* position: relative; */ width: 50vw; /* height: 60vh; */ /* max-width: 800px; */ /* display: flex; */ /* flex-direction: column; */ /* align-items: center; */ /* justify-content: center; */ } .swiper { width: 100%; height: 100%; } .icon-ic_close1 { position: absolute; z-index: 1002; } </style> 修改代码:要求:这是一个uniapp的开屏弹窗 根据代码写出来css样式,关闭按钮要放在图片的下方并图片保持间隔
最新发布
06-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值