How can I style an HTML INPUT tag so it maintains CSS when focused on Android 2.2+?

前端 未结 3 2090
故里飘歌
故里飘歌 2020-12-28 20:38

I was delighted to discover that Android 2.2 supports the position:fixed CSS selector. I\'ve built a simple proof-of concept, here:

http://kentbrewster.com/android-s

相关标签:
3条回答
  • 2020-12-28 21:22

    You might be able to solve it by using a bug in Android: http://code.google.com/p/android/issues/detail?id=14295.

    That is, don't display the input field right away. Instead, display an overlay div which listens on click and hides itself and shows the hidden input, and give the input focus. This somehow prevents Android from using the wierd input that gets placed on top of everything, and is instead using the browsers input field which you can style any way you want.

    As you'll note in the bug raport though, this doesn't work with input[type="number"]...

    0 讨论(0)
  • 2020-12-28 21:31

    This will probably not be resolved until Android switches to using Chrome for its WebView. The current Android browser creates an Android TextView on top of the page when an HTML input field is focussed. Apparently they don't style or position it correctly. You can see it go more wrong on pages that use contentEditable.

    The current Chrome-for-Android implements the WebKit IME interface, so input fields are drawn by WebKit (and lose some of the niceties of the Android TextView on ICS) and shouldn't have issues like this.

    0 讨论(0)
  • 2020-12-28 21:33

    The solution is to add:

    
        input {
            -webkit-user-modify: read-write-plaintext-only;
            -webkit-tap-highlight-color: rgba(255,255,255,0);
        }
    
    

    in your css.

    0 讨论(0)
提交回复
热议问题