移动端唤醒软键盘布局

在移动端开发中,经常会有 fixed 元素和输入框(input 元素)同时存在的情况。 但是 fixed 元素在有软键盘唤起的情况下,会造成原本布局的混乱问题,因为在IOS端软键盘唤醒后,fixed布局会失效,软键盘会把输入框顶起来(但是输入框不会贴近键盘底部),最近做了项目的评价功能,结合了安卓和IOS中布局的表现问题,写了一个DEMO,经过测试,可以完美解决这个问题

        <style>
            /*视图头部*/
            header {    
                position: fixed;
                height: 50px;
                left: 0;
                right: 0;
                top: 0;
                z-index: 9;
                width: 100%;
                background: greenyellow;
            }
            /*视图底部*/
            footer {
                position: fixed;
                height: 34px;
                left: 0;
                right: 0;
                bottom: 0;
                z-index: 9;
                background: greenyellow;
            }
            /*视图内容区域*/
            .box {
                position: absolute;
                top: 50px;
                bottom: 34px;
                overflow-y: scroll;
                height: 2000px;
            }

        </style>
    <body>
        <header>
            header
        </header>

        <!--内容视图区域-->
        <div class="box">
            <!--内容视图-->
        </div>

        <footer>
            <input type="text" placeholder="请填写商品评论。。。" />
            <button class="submit">提交</button>
        </footer>
    </body>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值