CSS hiding bottom part of layout when Keyboard is triggered - android

i have a webapp i'm trying to make responsive and i'm running into a problem on my Android 5.2 phone where when i click the input, it shows the keyboard and the form gets pushed down i think, leaving this ugly white area at the bottom whenever the keyboard is shown.
I'm using 100vh on the element that contains the background image, could that be what's causing the problem?
I'll link an image of the issue below taken from my mobile phone.
Has anyone run into this issue before? how did you fix it?

Use this for small screen devices :
body{
-webkit-box-sizing:border-box;
box-sizing:border-box;}

Rookie mistake, you must shouldn't use vh for heights, just let the content define the height and if necessary define min-heights, vh messes it up on Mobile whenever you scroll down.

Related

CSS styling for different devices & Android soft input

I'm using PhoneGap and JQueryMobile to create a mobile app that I want to deploy to both iOS and Android. The app is simple, and just consists of 3 bars: A header/search bar, a second bar (displays the results of the search), and the remaining screen is a that the user can write in.
Because I want to code my layout to look the same for the greatest # of devices, I've written my CSS for the layout of the app in %'s. Header is 6%, Second bar is 14%, ect. This appears to work decently for the devices I've tested for so far. I ran into an issue where the Android keyboard would squish the viewport height and therefore my layout. So I set the keyboard to resizePan and that solved the squishing issue. However now the bottom of the is not visible until the user closes the keyboard.
In the questions I've seen about that issue, the solution is to swap to "adjustResize" so that the user can scroll when the keyboard is active. I can't do this, because I want to avoid the layout-squish issue.
Is there a way to fix this without having to re-write the CSS? If I HAVE to re-write the CSS, how should I code the layout to look consistent on multiple devices? Do I have to use an extensive list of media queries for all possible devices?
Note: This isn't an issue for ios, because the soft-input keyobard overlays the textarea (like adjustPan) but still allows the user to scroll down and up to parts of the document outside of the view or covered by the keyboard.

make softkeyboard of Android platform to overlay above the content instead of pushing it upwards

Of course there were many similar questions to my problem but none of them worked for me. So,it forced me to open a new question.
So, I am developing an Hybrid mobile app where the main screen contains two independent section with their own input labels. So,when ever the input field got focused the native Android SoftKeyboard pushing the contents of lower section towards up, which eventually decreases the screen size.
Here, I don't want the keyboard to push the content up. The keyboard should be shown but it should be over lay on the section.
I've tried these things already:
android:windowSoftInputMode="adjustNothing", android:windowSoftInputMode="adjustPan" and some jquery code but in vain.
I am not sure it is possible.
However you can work around this, by specifying your element's height with viewport width vw measures.
For example:
div {
height: 40vw;
}
This won't work on landscape however.
You can also hide elements when the keyboard is opened (so instead of them being pushed up, they are just not seen) by assigning the class hide-on-keyboard-open
Like so:
<div class="button hide-on-keyboard-open"></div>

jquery causes keyboard to appear/disappear on android

I have a responsive web page that I want to reorder with jquery when going from one size to a smaller one. Everything is great except when I reorder an element (a DIV, for example) that has an input in it, like the search form:
$( '#searchfrm' ).insertAfter( '#bodyfrm' );
If I do this, when I click the input, the keyboard appears for a second and then disappears. This happens only on Android, on iPhone it works perfectly.
If I comment the code line, the input works perfectly on Android but I don't want the search form on top, but on the bottom of the page on the responsive design.
How do I prevent this from happening? Thanks!
I found that the problem was when reordering the elements. The reordering process was being done all the time so, in Android, when the keyboard appeared, jquery was reordering again, making the keyboard disappear. The solution was adding a variable in jquery to prevent the reordering process all the time and do it only once when going from 1024 to 700, for example.
I had a similar issue but found it was due to the $(window).on("resize",function(){...}); and not the .insertAfter script used to reposition the element.
If the element you reposition has an input field and that input field is in focus ~ the default behavior of Android opening the keyboard actually resizes the browser causing the function to loop. - REFERENCE: (dealing-androids-constant-browser-resizing). Changing the function to trigger on (load) as opposed to (resize) did the trick for me. $(window).on("load",function(){...});

Android iframe bug

I have an issue on my phone running Android 4.0.4.
I have an iframe with a text field and a couple of dropdowns, but the iframe is too wide to fit in the phone window when in portrait mode, so I get a horizontal scroll bar so I can scroll to see all of the fields.
The problem is, if I scroll the iframe to the right I can no longer select the text box or the dropdowns.
It looks like the device doesn't realise the iframe has been scrolled to the right, so for example, when the iframe first renders, the content is positioned left aligned. At this moment, one of the dropdowns is visible at the far right of the iframe. If I scroll the iframe all the way to the right and tap the screen where the dropdown used to be, I get the selection screen for the drop down even though the area of the screen I actually clicked had no element on it at all.
If I tap the screen where the dropdown actually is, I get no response at all.
I have a test page here:
http://snow.x10.mx/damian/page.html
Everything works fine on Firefox on the desktop, so it looks like it may be just an Android bug.
Can anybody suggest a workaround for it (other than making sure the iframe isn't wider than the screen) because I can't see an Android fix coming any time soon!
If anyone has an iPhone they can test it with, can you let me know if you have the same problem?
I've run into the same issue with Android 4.0.4
The same thing happens with vertical scrolling, and applies to input fields, links... Anything that should react to a touch/click event. If the element is visible before scrolling the position where it was is still reacting to the touch event after scrolling. And if it's not visible before scrolling there is nothing you can do to interact with that element.
I'm not sure what's causing this, but using a scrollbar plugin ( jScrollPane ) has solved it for me.
Good luck!

Android/Mobile Webkit CSS Background-Attachment:Fixed Not Working?

Am I just going crazy, or does background-attachment:fixed; really not work in the native Android browser?
I already implemented a simple fix by using two divs instead of one... The first div is positioned absolutely and contains the fixed background image, the other div goes on top of it and contains the scrolling content.
The issue with this fix (aside from the unnecessary complication) is that for some reason, when I am scrolling the content over the background image div, the background image disappears altogether! :(
Has anyone else found a workaround that isn't buggy, or how exactly are we supposed to work with this?
With native browser scrolling you cannot do that. It's a bug in the default Andriod browser. To implement a fixed element at the top or the bottom you have to apply position: fixed on it and then implement a custom scrolling on the other element which contains the content to scroll.
I used this Library for this kind of problems:
http://cubiq.org/iscroll-4
You can find examples on its page.

Categories

Resources