screen styling when virtual keyboard is active

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

Ideally, i would want the entire interface to have a custom styling that is seen on the ios (itouch / ipad) or android equivalent with the virtual keyboard present. See below for more details.

A custom set CSS hacking rules to be active, when the keyboard is "present", is also an acceptable solution.

Targets both androids and ios, on a website (HTML/JavaScript/CSS) Also note that the layout inside is: "fluid".

Edit: This was more design, then text; So the changes are not disorientating. At the lowest level, I just desire a design change with and without the virtual keys (Perhaps just a background change).

The question on which, this is a good or bad design idea, is debatable. However, I feel is irrelevant to the question. For such an exploit can have uses more then text (such as games, or interactive media).

Hence the bounty: Despite no longer needing the answer for the project I was working on (an alternative design was used). I still believe this question can benefit from being answered.

Default Behavior

                       +--------+                         |        | +------------+       +-+-hidden-+-+     | +--------+ | | |        | |   /   | |virtual | | | |        | |       | |  keys  | | | +--------+ |       | +--------+ | +------------+       +------------+ 

Desired Behavior

+------------+       +------------+    | +--------+ |       | +--------+ | | |        | |       | |visible | |     | +--------+ | | |        | |   /   | |virtual | | | |        | |       | |  keys  | | | +--------+ |       | +--------+ | +------------+       +------------+ 

回答1:

I'm not sure, is this the desired effect?. check this link

http://jsfiddle.net/UHdCw/3/

Update

(1). Assuming its a website & running on device browser. Then we can check the presence of virtual keyboard by checking the screen size.

Check in device browser - http://jsfiddle.net/UHdCw/8/show/

code : - http://jsfiddle.net/UHdCw/8/

(2). If you are building native app with HTML5 & Phonegap, things will be different. Since there is no direct API hook to check the keybord status, we have to write our own plugin in Phonegap.

In Android you can check show/hide status of keyboard by using native code [check here]. and have to write Phonegap plugin to get those events in our HTML.

[Phonegap is an example. I think most of the html to native frameworks have this kind of felicity to hook with native code ]

iOS update

As you said there is no change in height/position when keyboard is present. We can do one thing, when input gets the focus we can add shrink class and reduce the element sizes. Check following link.

http://jsfiddle.net/UHdCw/28/show/



回答2:

I encountered the same problem, this works for me:

 


回答3:

Have JavaScript apply a class to the body when an input element has focus.

$("input, textarea").focus(function(){  $(document.body).addClass('when-keyboard-showing');     }); $("input, textarea").blur( function(){  $(document.body).removeClass('when-keyboard-showing');  }); 

And then use @media queries to determine if mobile view:

@media (max-width:550px) {      body.keyboard-up .header { height:0; padding:0; } } 

The combination will let you stylize the page when the keyboard is up, on mobile. Thank you.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!