繁体   English   中英

键盘打开时,背景和页脚在phonegap中变得失真

[英]Background and footer get distored in phonegap when keyboard opens

我在phonegap中遇到屏幕问题。页面底部有一个后退按钮,但是当我打开键盘时,它位于键盘上方,并且背景图片变短了。如何设置它。我的HTML代码是:

<body >


 <div  class="wrapper" style="background-image: url('img/1.jpg');">
    <div  class="container">

            <div  style=" width: 100%;height:45%;">
                <img  src="img/logo.png" style="width: 60%;height: 95%;"/>
            </div>  
            <form class="form" id="myForm" method="GET" onSubmit="" style="margin-top: 13%">
            <input type="text" id="email" class="email" name="email" placeholder="Email Address">
            <input type="password" id="pass" class="pass" name="password" placeholder="Pass" style="float: left;">
            <input type="password" id="pass2" class="again" placeholder="Again" style="float: right;">
            <input type="text" id="phone_no" class="phone" name="phone" placeholder="Mobile Number">
            <button type="submit" class="continue" onclick="sign_up_pass();transit()" >Continue</button>
        </form>

<div style="width: 100%;height:auto ; position:absolute; bottom:0;left:0;background-color: black; ">
    <a><img src="img/left_arrow.png" style="float: left ;padding:10px;height:50px"/><p style="text-align: left;line-height: 50px;font-size: 22px;color: #9d988d;font-weight: bolder">Back</p></a></div>
</div>              

</div>
</div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</body>

而我的CSS代码是:

 @import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300);
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-weight: 1000;
}
body {
  font-family: 'montserrat_alternatesregular';
  color: #DCDCDC;
  font-weight: 1000;

}
body ::-webkit-input-placeholder {
  /* WebKit browsers */
  font-family: 'montserrat_alternatesregular';
  color: #DCDCDC;
  font-weight: 1000;
}
body :-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
 font-family: 'montserrat_alternatesregular';
  color: #DCDCDC;
  opacity: 1;
  font-weight: 1000;
}
body ::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  font-family: 'montserrat_alternatesregular';
  color: #DCDCDC;
  opacity: 1;
  font-weight: 1000;
}
body :-ms-input-placeholder {
  /* Internet Explorer 10+ */
  font-family: 'montserrat_alternatesregular';
  color: #DCDCDC;
  font-weight: 1000;
}
a{

    text-decoration: none;
    color: white
}



.wrapper {

  left:0;
  top:0;
  background-size:100% 100%;
  background-repeat: no-repeat;

}
.wrapper.form-success .container h1 {
  -webkit-transform: translateY(85px);
      -ms-transform: translateY(85px);
          transform: translateY(85px);
}
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
  background-size:cover;
  background-repeat: no-repeat;
  text-align: center;
}
.container h1 {
  font-size: 70px;
  -webkit-transition-duration: 1s;
          transition-duration: 1s;
  -webkit-transition-timing-function: ease-in-put;
          transition-timing-function: ease-in-put;
  font-weight: 150;
}

我的实际画面 在此处输入图片说明

键盘或检查元件打开后,背景变小并且后退按钮上升 在此处输入图片说明

请帮忙

由于css布局是按百分比设计的,因此一旦打开软键盘,便会重新调整容器的大小,从而缩小内容。

解:

在页面加载时,以像素为单位设置body的高度,如下所示:

var bodyObj = $("body");
bodyObj.css('height', window.innerHeight + "px");

从共享的html / css中看来,您具有“包装器” div的背景图像,但已为“容器” div添加了背景属性。 您应该为包装div设置背景属性,以避免背景图像崩溃。

但是您可以尝试使用position:relative代替position:absolute

<div style="width: 100%;height:auto ; position:absolute; bottom:0;left:0;background-color: black; ">
    <a><img src="img/left_arrow.png" style="float: left ;padding:10px;height:50px"/><p style="text-align: left;line-height: 50px;font-size: 22px;color: #9d988d;font-weight: bolder">Back</p></a></div>
</div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM