草庐IT

jquery - iOs 跳转包含 INPUT 的固定页脚

coder 2024-01-24 原文

我有一个 phoneGap-cordova 应用程序。其中我有一个页面有一个固定的输入页脚,但是每当在移动设备中打开一个软键(键盘)时,固定元素就会失去它的位置并向上跳,

我见过很多相同的解决方案,但运气不好。

这是我的页面的CSS:

.main {
  display: table;
  border-spacing:0px;
  margin-top:10px;
  margin-left: 18px;
  margin-right: 10px;
  height: auto;
   }

.imageIcon {
  display: table-cell;
  vertical-align:top;
  cursor: pointer;
}
.contentDiv {
  display: table-cell;
  vertical-align: middle;
  padding-left:12px;
  width:100%;
}
.nameAndId {
  /* background-color: aqua; */
  margin-top:6px;
  font-family: Roboto-medium;
  font-size: 13px;
}
.commentDetails {
    margin-top: 5px;
    font-size: 12px;
    word-break: break-word;
}
.ID
{
    font-size: 12px;
    display:inline;
}
.updateTime {
  float: right;
  margin-top: 16px;
  font-family: Roboto-light;
    font-size: 12px;
  color:#767676;
}

.footerClass
{   background:#ffffff;
    position:device-fixed; 
    bottom:0px;
    padding: 16px 0px;  
    width:100%;
    display:-webkit-box;
    -webkit-box-orient:horizontal;
    }

.cameraImage
{

    width:initial;
    margin-left: 18px;
    cursor: pointer;


}

.inputComment
{

    margin-left: 10px;
    -webkit-box-flex:1;
    margin-right:10px;
    padding-right:10px;
}

.inputCommentTextBox
{
    width:100%;
    outline: 0;
    border-left:0px;
    border-right:0px;
    border-top:0px;
    border-bottom-width: 1px;
    border-bottom-color:#767676;
    background-color: transparent;
    border-bottom-left-radius:5px;
    border-bottom-right-radius:5px;

}

.postImage
{

    width:initial;
    cursor: pointer;
    margin-right: 10px;


}

HTML:

<div id="mainComment" style="background-color:#ffffff; height:auto;padding-top:1px; padding: 1px 0px 20px;overflow-x:hidden;" >
    <div style="background-color:#ededed;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;">
        <div style="-webkit-box-flex:1;-webkit-flex:1 100%;-ms-flex:1 100%;flex:1 100%;text-align: center;-webkit-align-self: center;-ms-flex-item-align: center;align-self: center;padding-top:4px;padding-left: 20px;">Comments</div>
        <div class="cameraImage showPen"><img data-ng-click="returnBack()" style="width: 35px;height: 35px;padding: 10px;" src="close.png" alt="Camera Image"/></div>
    </div>

    <div data-ng-repeat="name in names" >

        <div  class="main" style="background:#ffffff;padding: 10px;">
            <div class="imageIcon"><img style="height:56px;width:56px;"src="user.png" alt="UserMale" /></div>
            <div class="contentDiv">        
                    <div class="nameAndId">{{name}},<p class="ID"> {{xyz}}</p></div>
                    <div class="commentDetails">{{abc}}</div>
                    <div class="updateTime timeago" title="" >{{yzk}} ago</div>
            </div>
        </div>
        </div>

    <div id="footerId" class="footerClass" >
            <div class="cameraImage showPen" data-ng-show="false"><img data-ng-click="returnBack()" style="width:20px;height:20px;" src="close.png" alt="Camera Image"/></div>
            <div class="inputComment"><input onfocus="this.value = this.value;" id="commentBox" data-ng-model="commentData" type="text" placeholder="Write your Comment" class="inputCommentTextBox"></div>  
            <div class="postImage"  data-ng-show='postSelector'><img  style="width:26px;height:22px;" src="send.png" alt="Search Image"/></div>
            <div class="postImage" data-ng-show='loadMoreContentComment'>

            </div>
    </div>
</div>

所以每当我将注意力集中在输入 int 上时,固定的页脚就会从它的位置移位并向上移动。

请给我建议解决方案,因为我已经经历了很多解决方案但还没有运气。

谢谢

最佳答案

试试这个

$("input").on("focus", function(event){
    if(event.handled !== true)
    {
        $(".footerClass").css({ 'position': 'absolute' });
        $(".footerClass").css('display', 'none');        
    }
    return false;
});

$("input").on("blur", function(event){
   if(event.handled !== true)
   {        
      if(!$("input").is(":focus")){
          $(".footerClass").css({ 'position': 'fixed' })
          $(".footerClass").css('display', 'block');           
      }
   }
   return false;
});

关于jquery - iOs 跳转包含 INPUT 的固定页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30908683/

有关jquery - iOs 跳转包含 INPUT 的固定页脚的更多相关文章

  1. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  2. ruby - 检查字符串是否包含散列中的任何键并返回它包含的键的值 - 2

    我有一个包含多个键的散列和一个字符串,该字符串不包含散列中的任何键或包含一个键。h={"k1"=>"v1","k2"=>"v2","k3"=>"v3"}s="thisisanexamplestringthatmightoccurwithakeysomewhereinthestringk1(withspecialcharacterslike(^&*$#@!^&&*))"检查s是否包含h中的任何键的最佳方法是什么,如果包含,则返回它包含的键的值?例如,对于上面的h和s的例子,输出应该是v1。编辑:只有字符串是用户定义的。哈希将始终相同。 最佳答案

  3. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  4. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  5. jquery - 我的 jquery AJAX POST 请求无需发送 Authenticity Token (Rails) - 2

    rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送

  6. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  7. ruby - 在 Ruby 中将整数格式化为固定长度的字符串 - 2

    有没有一种简单的方法可以将给定的整数格式化为具有固定长度和前导零的字符串?#convertnumberstostringsoffixedlength3[1,12,123,1234].map{|e|???}=>["001","012","123","234"]我找到了解决方案,但也许还有更聪明的方法。format('%03d',e)[-3..-1] 最佳答案 如何使用%1000而不是进行字符串操作来获取最后三位数字?[1,12,123,1234].map{|e|format('%03d',e%1000)}更新:根据theTinMan的

  8. ruby-on-rails - 使用包含多个关联和单独的条件 - 2

    我的Gallery模型中有以下查询:media_items.includes(:photo,:video).rank(:position_in_gallery)我的图库模型有_许多媒体项,每个都有一个照片或视频关联。到目前为止,一切正常。它返回所有media_items包括它们的photo或video关联,由media_item的position_in_gallery属性排序。但是我现在需要将此查询返回的照片限制为仅具有is_processing属性的照片,即nil。是否可以进行相同的查询,但条件是返回的照片等同于:.where(photo:'photo.is_processingIS

  9. jquery - 如何将 AJAX 变量从 jQuery 传递到他们的 Controller ? - 2

    我有一个电子邮件表格。但是我正在制作一个测试电子邮件表单,用户可以在其中添加一个唯一的电子邮件,并让电子邮件测试将其发送到该特定电子邮件。为了简单起见,我决定让测试电子邮件通过ajax执行,并将整个内容粘贴到另一个电子邮件表单中。我不知道如何将变量从我的HAML发送到我的Controllernew.html.haml-form_tagadmin_email_blast_pathdoSubject%br=text_field_tag'subject',:class=>"mass_email_subject"%brBody%br=text_area_tag'message','',:nam

  10. ruby - 我怎样才能只写一次 "Text"并同时检查 path_info 是否包含 'A' ? - 2

    -if!request.path_info.include?'A'%{:id=>'A'}"Text"-else"Text"“文本”写了两次。我怎样才能只写一次并同时检查path_info是否包含“A”? 最佳答案 有两种方法可以做到这一点。使用部分,或使用content_forblock:如果“文本”较长,或者是一个重要的子树,您可以将其提取到一个部分。这会使您的代码变干一点。在给出的示例中,这似乎有点矫枉过正。在这种情况下更好的方法是使用content_forblock,如下所示:-if!request.path_info.inc

随机推荐