【发布时间】:2016-11-20 17:50:34
【问题描述】:
更新:看起来这只是 Safari iOS 上的特定错误。作为 Web 应用程序加载的网站(保存在主页上)不显示 相同的间隙/缓冲区。你应该只能解决这个问题。
JSBIN - 在 Mobile safari 与其他浏览器上查看。
实时输出:http://output.jsbin.com/winuta/
JSBin:http://jsbin.com/winuta/edit?html,js,output
原帖
这是 DIV 中文本区域的一个非常基本的精简版本,底部固定。
我正在使用 Flat Bootstrap Admin V3 模板,该模板必须调试很长时间,因为许多消息传递部分存在问题。
我的页面在所有浏览器上都能正确显示,除了 Mobile Safari,它在我的文本字段成为焦点时在键盘和正文之间创建了一个缓冲区/间隙。
我设法解决了大部分错误,但是在移动设备方面,我在 iOS Safari 上遇到了这个问题,当 我专注于文本区域时,它在网页下创建 额外的缓冲区(我在 100VH 使用 body max-height - Buggy 我知道,但我已经使用 JS 和 $(window).innerHeight() 解决了这个问题,效果很好),没有不管我怎么做。
我尝试使用 JS 将所有不同的 div 高度(包括身体高度)调整为再减去 60 像素,但仍然存在差距。所有其他浏览器都将粘贴在键盘的正上方,但 iOS safari 除外。
任何人都可以解释一下吗?
文字区号
<div class="footer">
<div class="message-box">
<textarea id="draftmsg" placeholder="type something..." class="form-control"></textarea>
<button id="sendmsg" class="btn btn-default"><i class="fa fa-paper-plane" aria-hidden="true"></i><span>Send</span></button>
</div>
这个模板主要是基于 flex 但我使用的页脚
.footer {
position: relative; /*Relative to the text display area which occupies whole viewport minus footer*/
bottom: 0;
}
上图显示了没有键盘和 用户无法滚动到文本区域,因为文本区域粘在 底部。
但图像显示了移动设备中键盘和文本区域之间的间隙 野生动物园
上图显示 Chrome 和 Firefox 显示的其他移动浏览器 没有额外的缓冲区就可以了。
更新(来自 cmets 的问题的答案)
我的元标题已经设置如下
<meta name="viewport" content="initial-scale=1.0, user-scalable=0, width=device-width, height=device-height"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
页脚的完整 CSS
.app-messaging .messaging > .footer {
width: 100%;
padding: 8px;
background-color: #dfe6e8; }
.app-messaging .messaging > .footer .message-box {
background-color: #FFF;
border-radius: 2px;
box-shadow: 0 1px 1px #c8d1d3;
width: 100%;
height: 80px;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-ms-flex-align: start;
align-items: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
border-top: 1px solid #dfe6e8; }
.app-messaging .messaging > .footer .message-box textarea, .app-messaging .messaging > .footer .message-box button {
margin-bottom: 0;
border: 0;
height: 100%;
border-radius: 0; }
.app-messaging .messaging > .footer .message-box textarea {
-ms-flex: 1;
flex: 1; }
.app-messaging .messaging > .footer .message-box button {
border-left: 1px solid #dfe6e8;
color: #29c75f; }
.app-messaging .messaging > .footer .message-box button .fa {
margin-right: 1rem; }
#draftmsg {
line-height: normal;
padding-bottom: 0;
margin-bottom: 0;
}
【问题讨论】:
-
你能分享完整的页脚相关css吗?也试试left:0;底部:0;在页脚类样式上。
-
@PraveenPoonia 我已经更新了我的问题以显示相关的 CSS。尝试左:0 不起作用。我必须再次说明,这只是移动 css 上的问题,其他一切似乎都完美无缺。
-
有时甚至在 bootstrap 上也需要使用 css-reset。你用过吗?正如您所看到的,当浏览器中的某些内容有所不同时,我认为这与默认值有关
-
你试过设置
body的position: relative吗? -
@S.Gholizadeh 你能详细说明一下吗
标签: javascript jquery css mobile-safari