我是靠谱客的博主 粗心蜡烛,这篇文章主要介绍打开input输入的时候,css中position:absolute/fixed定位的时候,定位元素上移问题解决...,现在分享给大家,希望可以做个参考。

1、异常代码

  

<style>
  .box{
    min-height: 100vh;
    width: 100%;
    position: relative;
  }
  .position{
    position: absolute;
    left: 0;
    width: 100%;
    bottom: 0;
  }
</style>
<body>
  <div class="box">
   <input type="text"/> <div class="position"> 底部 </div> </div> </body>

  

  这样的代码,我们可以看到底部的position会随着 input 输入,高度变化而上来 

  这样有可能底部会挡住元素

 

2、解决方法

<style>
  .box{
    min-height: 100vh;
    width: 100%;
    position: relative;
  }
  .position{
    position: absolute;
    left: 0;
    width: 100%;
    bottom: 0;
  }
</style>
<body>
  <div class="box">
    <input type="text">
    <div style='height: 400px'></div>
    <div class="position">
      底部
    </div>
  </div>
</body>

  

  在里面添加一个元素,使得内容的高度大于 输入时候 屏幕的高度

 

  这样就解决了

 

 

 

   

 

转载于:https://www.cnblogs.com/jiebba/p/9837823.html

最后

以上就是粗心蜡烛最近收集整理的关于打开input输入的时候,css中position:absolute/fixed定位的时候,定位元素上移问题解决...的全部内容,更多相关打开input输入内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部