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

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-scroller/scroller.html
... which works like a charm. When I attempt to add an INPUT tag to my header, however, I hit trouble. On focus, every device I've tried so far clones the INPUT tag, gives it an infinite Z-index, and repaints it on top of the old tag. The clone is in roughly the right position, but most of its parent's CSS (including, of course, position:fixed) is ignored. The cloned INPUT tag is the wrong size and shape, and when I scroll the body of the page, it scrolls up and off the screen.
Once it's off screen, hilarity ensues. Sometimes the device will force the scrolling part of the body back down so the cloned blank is back in view; sometimes the keyboard goes away even though the visible box seems to remain in focus; sometimes the keyboard cannot be dismissed even though the INPUT blank is clearly blurred. Here's an example you can run on your Android 2.2 device to see what's happening:
http://kentbrewster.com/android-input-style-bug/
Styling input:focus has not done the trick for me yet, nor have many different brute-force attempts to listen for focus() and blur() with JavaScript and do the right thing with focus and the keyboard.
Thanks very much for your help,
--Kent

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.

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.

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"]...

Related

Angular - Button focus is lost when changing back and forth between windows

I have a toolbar of buttons that are gray by default but when one button is clicked on that button is made white to indicate that that is the page you are on. This is achieved using a class and the below css.
.btn-details:focus {
color: #fff;
}
This works fine except when I change windows and then go back. For example, if I have my page open it is working find, then I switch to an Excel window and then back to my page the white highlighting is now gone. How can I keep the button in focus even when the window is changed?
Unfortunately I think you need to take your time to focus on how CSS works.
You are using the: focus selector. Know that it does what you asked it to. If the button loses focus and your style no longer holds.
I think this is exactly what happens when you use other apps.
I advise you to add a CSS class on the button clicked and to remove this same class on the other buttons.
If you have difficulty implementing this, please come back to me. I would make a small example depending on your level.
See you soon !

Transition not being captured by subtree & attribute breakpoints Chrome developer tools

I have a webpage on which if a tab key is pressed when in the last textbox a side pane from the right slides(like a side menu).
In chrome development tools I can see it is an aside tag with classes control-sidebar control-sidebar-dark but setting DOM break points(subtree & attribute) on the aside tag is not capturing anything.
On looking into DOM it seems like it is not being manipulated at all(which I expected sliding in should be doing) as I do not see the color blink on HTML tags that chrome developer tool shows for the affected elements.
I was expecting the javascript to be handling the sliding in of the aside tag but how could it be determined in this scenario? Could this be due to CSS only animation or something if yes than how to debug that?
I also tried to record in the animation tab of developer tools but it also stays blank.
This is happening on a privileged section of the site so I m sorry for not being able to put code sample or URL.
PS: The template is some modified version of http://www.ampleadmin.wrappixel.com/ampleadmin-html/ampleadmin-rtl/index.html(the navigation panel on right) but it is getting recorded in dev tool animation panel while mine doesnt.
I found out the cause. There are anchor tags inside the panel which get focused on when the tab is pressed from last textbox. There was no animation,CSS or JS involved.
Anchor(A) tags are focus able by default and the panel dont slide in when they are removed.

iOS input in fixed container focus bug

I am having a strange bug in ios safari where a position:fixed sidebar with an input in it which allows a user to perform a search query. Everything is fine when to scrollTop of the page is 0 (no scrolling occurred, top of page). At this state the input is focusable and the user can enter stuff in the input. However when the user scrolls a few pixels down the input is no longer focusable and the user can not input anything, nor does the keyboard show.
Anyone else ever encountered this bug or know a fix/hack that could solve this?
Thanks,
K.
This is not bug, when you tap the textFiled it becomes FirstResponder and you can enter text in it using keyboard. When you scroll the scrollView, textField will resign as FirstResponder and scrollview will become FirstResponder. So now you want be able edit text in textfield unless you tap it again.
Regarding keyboard not showing up, this is because when textfield resigns as FirstResponder it will call textFieldShouldEndEditing: delegate method and you might be returning YES in this method.
I changed all fixed containers to absolute positioned containers and now it works. Guess position:fixed still has some side effects in ios safari.

Does hiding a div load the information?

Just wondering if when i display a div as hidden does the information gete loaded then hidden or does it get loaded when it is shown? can't remember the ters but it's like display="none" or something.
Thanks
This question is similar to yours. Does display:none keep elements from loading?
The part that relates to your question is this ->
Nope. display: none will only prevent the element from being
displayed; it will be loaded nevertheless.
You can watch this happen in the element inspector of your choice
(e.g. in Firebug or IE8's dev tools).
The best way is probably to create the Video element using JavaScript
afterwards, or - if you want a fail-safe solution in case JS is turned
off - you could use an iframe that loads the video if the user clicks
a link.
Hope that helps!
It still gets loaded into the DOM, but the browser doesn't show it since there is a hint to hide it.
Just use a DOM inspector like IE deveopler tools to inspect it, and you will see it with display:none
There are couple of CSS styles that you can use to hide the information from being displayed.
display: none and visibility: hidden
Both of them will actually load the DOM content but does not display them.visibility: hidden takes the space required for that DOM element accordingly in the layout eventhough it does not display the element. But display: none considers that the element is not present in the DOM and does not occupy any space in DOM corresponding to that element.
Please see this: http://jsfiddle.net/JSWorld/ADSmc/

Chrome "Developer Tools" element - hide annoying yellow dimensions box

How do I hide the annoying yellow box that appears under html fields when I hover over elements in the Chrome "Developer Tools" elements panel - it's driving me nuts as I can't see the bottom of my labels etc...
From the posted bug: "https://code.google.com/p/chromium/issues/detail?id=282493". If you hold keyboard Control (Ctrl) key before hovering the element (or command on a mac) the tooltip won't show. Not the ideal solution but it works as long as you know about it
You might want to check Chrome 16 which got an improved element tooltip. Please comment on the bug and mention specific issues that you want to get fixed.
You can pretty easily tweak devtools yourself. Basically, follow these instructions to get started.
Then, inside inspector.js, tweak WebInspector.highlightDOMNode, by applying this small patch.
1150,1151c1150
< // Do not highlight the DOM node.
< //this.highlightDOMNodeForTwoSeconds(nodeId);
---
> this.highlightDOMNodeForTwoSeconds(nodeId);
Fore more info, check out this post on extending Chrome DevTools.