HTML5 Search Input: No Background Image in Chrome? - css

I have been pulling my hair out trying to get Chrome to style my search input with a background image. Firefox has no problem, but I fear it's because it treats the input as a regular text input. Is this simply not possible?
Try this as a demo:
<input type="search" />
​input[type="search"] {
background: transparent
url(http://google.com/intl/en_ALL/images/srpr/logo1w.png) no-repeat 0 0;
}​​​​​​
If it worked correctly, it should put Google's logo (or part of it) as the background image for the "Search" input. But as you will see when you look at this in Chrome, it DOES NOT WORK. Any ideas, or is this just one of HTML5's quirks? :\

You can get Chrome (and Safari) to play along better with your styles on an HTML5 search field (including background images) if you apply this in your CSS:
-webkit-appearance: none;
You may also want to change -webkit-box-sizing to...
-webkit-box-sizing: content-box;
...since it appears that Webkit defaults this to the border-box value (basically the old IE5 box model).
Be warned, there's still no (apparent) way to have any effect on the position/appearance of the field-clearing button, and since only Webkit generates that button, you may find some new cross-browser annoyances to deal with.

Complete solution to remove all extra design caused by browser. This will change the search field to normal input field
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
display: none;
}
input[type="search"]{
-webkit-appearance: none;
-webkit-box-sizing: content-box;
outline:none;
}

Like you said, Mozilla treats search inputs as text. For Webkit browsers however (Chrome, Safari), the search input is styled as a client created HTML wrapper for the internal Webcore Cocoa NSSearchField. This is what gives it the round edges and the 'x' button to clear itself when there is text within it. Unfortunately it seems that not only are these extra features inaccessible by CSS/JS for the time being, but it also seems that there's no W3 specification for what CSS properties can be applied to this element as well as other new HTML5 elements. Until there is such a specification I wouldn't expect to have consistent behavior.

The cancel button can be styled with the following
input[type="search"]::-webkit-search-cancel-button {
/* Remove default */
-webkit-appearance: none;
/* Now your own custom styles */
height: 10px;
width: 10px;
background: red;
/* Will place small red box on the right of input (positioning carries over) */
}
Styling can be removed using
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
display: none;
}
http://css-tricks.com/7261-webkit-html5-search-inputs/

Related

Placeholder font-size bigger than 16px

I have read a couple of articles about styling the placeholder of an input field using ::-webkit-input-placeholder in HTML5. It works perfectly, except for one thing.
If I try to increase the font-size to a value higher than 16px, the text gets "cut" at the bottom. This happens regardless of height and padding of the input itself. Does anyone know a way of avoiding this problem, either using pure CSS or javascript?
I have added a screenshot of two inputfields where the placeholders have an font-size of 20px
Jsfiddle: https://jsfiddle.net/bvwdg86x/
The input and its placeholder must have matching font styles
input {
display: block;
width: 400px;
padding: 0 20px;
}
input,
input::placeholder {
font: 20px/3 sans-serif;
}
<input type="text" placeholder="Example Input">
A note about placeholder accessibility
The screenshot included in the question shows the placeholder values being used as labels. This technique may be problematic for users of assistive technology and is considered an accessibility anti-pattern.
From W3C › WAI › Placeholder Research › Avoid use of placeholder values:
A placeholder attribute should not be used as an alternative to a label. The placeholder is a short hint intended to aid the user with data entry so it should not be identical to the label element. The placeholder may not be available to assistive technology and thus may not be relied upon to convey an accessible name or description -- it acts similar to fallback content.
See also:
Don't Use The Placeholder Attribute - Smashing Magazine
Placeholders in Form Fields Are Harmful - Nielsen Norman Group
Placeholder Attribute Is Not A Label! - Web Axe
Does using a placeholder as a label comply with WCAG 2? - Stack Overflow
Placeholder styles will not resize an input field and will not affect its box model. Add font-size to your input to fix the placeholder from getting cut off.
You also might consider adding placeholder styles for other browsers...
::-moz-placeholder {} /* Firefox 19+ */
:-moz-placeholder {} /* Firefox 18- */
:-ms-input-placeholder {} /* IE */
You have to add 'overflow: visible' to the placeholder in your css to get rid of the cropping.
::placeholder{
overflow: visible;
}
input {
width: 450px;
padding: 0px 15px;
}
input,
input::-webkit-input-placeholder {
font-size: 25px;
line-height: 4;
}
<input type="text" placeholder="My Cool Placeholder Text">
Meanwhile, the browser vendors implemented the ::placeholder CSS pseudo-element.
You can find the current state of browser compatibility on caniuse.com.
Currently (2019-04-29) there are following notes:
::-webkit-input-placeholder for Chrome/Safari/Opera (Chrome issue #623345)
::-ms-input-placeholder for Edge (also supports webkit prefix)

Editing input type="search" Pseudo-element Button ('x')

I'm trying to make a search bar that will look nice. What I did is, I made an image of an search bar and I'm adding the image to the back-ground of the input and I'm editing the place and the size that the font will appear.
The only thing that I can't find a way to edit is the small 'x' button that appears when I'm using input type search.
I want to move it a little bit left so it will fix my search bar image.
Here is my HTML:
<input id="search" name="Search" type="search" value="Search" />
Here is my CSS:
#search{
width: 480px;
height: 49px;
border: 3px solid black;
padding: 1px 0 0 48px;
font-size: 22px;
color: blue;
background-image: url('images/search.jpg');
background-repeat: no-repeat;
background-position: center;
outline: 0;
}
For anyone finding themselves here (as I did) thinking "how do I inspect this element to apply custom styles?", you'll need to enable the user agent shadow DOM to make these vendor elements accessible.
For WebKit (Safari) & Blink (Chrome,Edge,Opera,Brave) browsers, follow these steps:
Open DevTools (Ctrl+Shift+I)
Find the gear icon, top-right and click to open up the dropdown menu
In the context menu that opens, under "Preferences", find "Elements" towards the bottom and enable "Show user agent shadow DOM"
As you can see, I'm a man of culture, if there is a dark theme, I use it
Styling the "x" cancel search button in Webkit browsers
Assuming you're talking about "Cancel search" [X] icon that appeas in Webkit browsers only (Chrome, Safari, Opera) you can use -webkit-search-cancel-button pseudo-element. E.g:
#Search::-webkit-search-cancel-button{
position:relative;
right:20px;
}
Demo: http://jsfiddle.net/5XKrc/1/
Screenshot:
Using this approach you can even create your own cancel button, for example this style:
#Search::-webkit-search-cancel-button{
position:relative;
right:20px;
-webkit-appearance: none;
height: 20px;
width: 20px;
border-radius:10px;
background: red;
}
Instead of [X] will create a red circle.
Demo http://jsfiddle.net/5XKrc/3/
Screenshot:
For IE10 and above you can use following to move the button:
#Search::-ms-clear{
margin-right:20px
}
Oh and do use placeholder="Search" instead of value="Search" - it will display word "search" when input is empty - and will automatically remove it when user types something.
2022 Cross-browser consistent approach
Here is a cross-browser implementation of the Clear Search "x" button, It uses the solid times-circle SVG from FontAwesome for the icon and works for both dark and light backgrounds. It also standardizes Safari to adopt the Chrome implementation to only show the icon when the form field has focus.
input[type="search"] {
border: 1px solid gray;
padding: .2em .4em;
border-radius: .2em;
}
input[type="search"].dark {
background: #222;
color: #fff;
}
input[type="search"].light {
background: #fff;
color: #222;
}
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
height: 1em;
width: 1em;
border-radius: 50em;
background: url(https://pro.fontawesome.com/releases/v5.10.0/svgs/solid/times-circle.svg) no-repeat 50% 50%;
background-size: contain;
opacity: 0;
pointer-events: none;
}
input[type="search"]:focus::-webkit-search-cancel-button {
opacity: .3;
pointer-events: all;
}
input[type="search"].dark::-webkit-search-cancel-button {
filter: invert(1);
}
<input type="search" placeholder="search" class="light">
<input type="search" placeholder="search" class="dark">
NB 1. This S.O. question is explicitly about the clear button pseudo element, which is only supported in Webkit-based browsers (Edge, Safari, and Chrome). Currently (2022) Firefox supports the search clear button behind a feature flag only. Until Firefox releases this feature publicly, the only true cross-browser approach that supports Firefox is via a workaround that leverages HTML+CSS with an absolutely positioned <input type="reset"> to clear the entire form when clicked. See stackoverflow.com/a/37846330 Note that this workaround will clear all radio/checkbox selections and other fields if your search form has more than just a single search field.
NB 2. your mileage may vary in Edge, which is also Webkit–based. In my testing (via BrowserStack) some versions of Edge did not support setting a background-image: url() in the ::-webkit-search-cancel-button pseudo-class.
I want to move [the small 'x' icon] a little bit left so it will fix my search bar image.
Users expect things not to move much is UIs. If you decide to move the 'x' icon consider using pseudo-classes and move your search icon instead:
If the search icon is embedded your background image move it into a second image with role="presentation" attribute and place it immediately after your input in the markup:
<input id="search" name="Search" type="search" value="Search" />
<svg role="presentation" class="i-search" viewBox="0 0 32 32" width="14" height="14" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3">
<circle cx="14" cy="14" r="12" />
<path d="M23 23 L30 30" />
</svg>
Position it where the user expects:
#search + svg {
margin-left: -30px;
margin-bottom: -2px;
}
Then hide and show it using the :placeholder-shown pseudo-classes:
#search + svg {
visibility: hidden;
}
#search:placeholder-shown + svg {
visibility: visible;
}
You may style the 'x' icon if you wish. But you might not want to anymore.
Does a simple "X" with a dark or light backdrop using a single block of CSS rules. Run code snippet to see example.
/* light backdrops only */
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
display: inline-block;
width: 12px;
height: 12px;
margin-left: 10px;
background:
linear-gradient(45deg, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 43%,#000 45%,#000 55%,rgba(0,0,0,0) 57%,rgba(0,0,0,0) 100%),
linear-gradient(135deg, transparent 0%,transparent 43%,#000 45%,#000 55%,transparent 57%,transparent 100%);
}
/* dark backdrops only */
input[type="search"][value="dark"]::-webkit-search-cancel-button {
background:
linear-gradient(45deg, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 43%,#fff 45%,#fff 55%,rgba(0,0,0,0) 57%,rgba(0,0,0,0) 100%),
linear-gradient(135deg, transparent 0%,transparent 43%,#fff 45%,#fff 55%,transparent 57%,transparent 100%);
}
<input type="search" value="light">
<input type="search" value="dark" style="background:black; color:white;">
Ref: https://stackoverflow.com/a/52141879/8762323
#input[type="search"]::-webkit-search-cancel-button {
// Using the two lines below will allow you to insert a image
-webkit-appearance: none;
-webkit-user-modify: read-write !important;
height: 28px;
content: url("clear button.png");
Just to highlight better how to figure out such kinds of things by ourselves. As shown and mentioned in #UncaughtTypeError answer above
https://stackoverflow.com/a/58484957/7668448
Also in the last section I do go to show how to do different things including changing the color. And with examples.
I loved the answer because it was teaching us how to fish rather than here is the fish
I want to clarify that further for others. Who may didn't notice.
By enabling the show user agent shadow dom in elements section of preferences in devtools.
Now you'll be able to access the shadow dom that is created by the agent (browser engine or browser shortly). In dev tools.
Get to know how to select the element
You can manipulate and experiment faster through the dev-tool. And figuring out properties and default values and what doesn't work. (example at the end)
What is shadow dom?
From Mozilla doc Using_shadow_DOM
An important aspect of web components is encapsulation — being able to keep the markup structure, style, and behavior hidden and separate from other code on the page so that different parts do not clash, and the code can be kept nice and clean. The Shadow DOM API is a key part of this, providing a way to attach a hidden separated DOM to an element. This article covers the basics of using the Shadow DOM.
You can learn more about it. On the link above.
How to figure out how you would refer to those hidden elements
After enabling showing the agent shadow dom. Now you can see those hidden dom elements.
Select the element. And check the Styles corresponding selector. As shown by the red box in the illustration above.
input[type="search" i]::-webkit-search-cancel-button {
}
And that's it.
Can test an example below:
https://codepen.io/mohamedlamineallal/pen/JjZmdPv
See before enabling and after enabling the agent dom shadow.
And for demonstration purposes. You can see, I changed the color using filter, resize the button with padding, and repositioned it with margin-right.
Elements around manipulating the clear button
A great deal with this method is that now you can use the Dev-tool to experiment faster. That includes figuring out what doesn't work at a better speed. Example mask-image with background-color. Or pseudo-element .before.
Things we can figure out:
to position, we have to use margin-right
resize the clear button with padding
To show and hide we got to use opacity
appearance can allow us to hide the default behavior fully. [If we want to disable the default button. We can use appearance: none; (default: appearance: auto;)]
We can see all the default settings
To replace the button, use background-image with URL no-repeat and center. Also, set the height and width
... that at a fast glimpse.
Otherwise, if you want to just change the color, you can with using a filter with (invert, sepia, saturate, hue, brightness, contrast) as in
filter: invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
(code pen)
You can use the calculator here: 1, 2
You can see the details of that method here (SO answer)
or also the svg filters method (SO answer) which I guess it's more ideal (why in the SO answer [link]).
filter: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg">\
<filter id="recolor" color-interpolation-filters="sRGB">\
<feColorMatrix type="matrix" values="\
0 0 0 0 R\
0 0 0 0 G\
0 0 0 0 B\
0 0 0 A 0\
"/>\
</filter>\
</svg>\
#recolor');
read the answer (link).
Reimplement all
And surely if the desired output is more complex. Simply disabling the default behavior and re-implement it fully would be more clean and easy and faster.
Using appearance: none; will hide and disable the default behavior.
input[type="search" i]::-webkit-search-cancel-button {
appearance: none;
}
You can use position: absolute; on a span element to keep the input behavior as outline on focus (can use padding-right for not letting text overflow below the button) and you can also use CSS URL for background-image (SVG icons, you can have utf8 inline encoded SVG where you can change the color, including dynamically if needed) ...
[take keywords, if they make sense check them]
Absolutely: don't use pseudo-element :after. You can't add a js event listener to it. Using a span is cleaner and faster.
Here are some examples:
Using span with absolute position
Using :after pseudo-element and using the event-pointer workaround. (event bubbling make it possible) (you can read the comment in the playground)
The :after example demonstrate. Using a flex-box system. Hidding input outline and border. And re-implementing them. Could have used that in the span example. use outline: none; to disable the default outline.
I advise always to use the dom el (span) way.
I'm not sure is this what you were looking for, but you can style your search bar like this
fiddle
HTML
<div id="input">
<input type="text" id="tb" />
<a id="close" href="#"><img src="http://www.ecoweb.info/sites/default/files/tips-close.png"></a>
</div>
CSS
#tb
{
border:none;
}
#input
{
padding:0px;
border: 1px solid #999;
width:150px;
}
#close
{
float:right;
}

Bootstrap 3 Styled Select dropdown looks ugly in Firefox on OS X

When styling a form <select> element in Bootstrap 3, it renders an ugly button on the in Firefox on OS X:
(http://bootply.com/98385)
This has apparently been a known issue for a while, and there are a number of hacks and workarounds, none of which are very clean (https://github.com/twbs/bootstrap/issues/765). I'm wondering if anyone has found a good solution to this issue other than using Bootstrap dropdowns or extra plug-ins. I have deliberately chosen to use HTML <select>'s rather than Bootstrap dropdowns because usability is better with long lists on mobile devices.
Is this a Firefox problem or a Bootstrap problem?
Details: Mac OS X 10.9, Firefox 25.0.1
Update 12/4/13: I did a side-by-side comparison of how each browser renders the <select>'s on OS X 10.9 using Firefox, Chrome, and Safari, in response to #zessx (using http://bootply.com/98425). Obviously, there is a big difference between how the <select> form element is rendered across browsers and OS's:
I understand that a <select> tag is handled differently based on what OS you are using, as there are native OS-based controls that dictate the styling and behavior. But, what is it about class="form-control" in Bootstrap that causes a <select> form element to look different in Firefox? Why does the default, un-styled <select> in Firefox look okay, but once it gets styled, it looks ugly?
You can actually change the grey box around the dropdown arrow in IE:
select::-ms-expand {
width:12px;
border:none;
background:#fff;
}
Building on the excellent answers by rafx and Sina, here is a snippet that only targets Firefox and replaces the default button with a down-caret copied from Bootstrap's icon theme.
Before:
After:
#-moz-document url-prefix() {
select.form-control {
padding-right: 25px;
background-image: url("data:image/svg+xml,\
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' width='14px'\
height='14px' viewBox='0 0 1200 1000' fill='rgb(51,51,51)'>\
<path d='M1100 411l-198 -199l-353 353l-353 -353l-197 199l551 551z'/>\
</svg>");
background-repeat: no-repeat;
background-position: calc(100% - 7px) 50%;
-moz-appearance: none;
appearance: none;
}
}
(The inline SVG has backslashes and newlines for readability. Remove them if they cause trouble in your asset pipeline.)
Here is the JSFiddle
Actualy you can do almost everything with dropdown field, and it will looks the same on every browser, take a look at code example
select.custom {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20fill%3D%22%23555555%22%20%0A%09%20width%3D%2224px%22%20height%3D%2224px%22%20viewBox%3D%22-261%20145.2%2024%2024%22%20style%3D%22enable-background%3Anew%20-261%20145.2%2024%2024%3B%22%20xml%3Aspace%3D%22preserve%22%3E%0A%3Cpath%20d%3D%22M-245.3%2C156.1l-3.6-6.5l-3.7%2C6.5%20M-252.7%2C159l3.7%2C6.5l3.6-6.5%22%2F%3E%0A%3C%2Fsvg%3E");
padding-right: 25px;
background-repeat: no-repeat;
background-position: right center;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
select.custom::-ms-expand {
display: none;
}
https://jsfiddle.net/x76j455z/10/
There is a slick-looking jQuery plugin that apparently plays nice with Bootstrap called SelectBoxIt (http://gregfranko.com/jquery.selectBoxIt.js/). The thing I like about it is that it allows you to trigger the native select box on whatever OS you are on while still maintaining a consistent styling (http://gregfranko.com/jquery.selectBoxIt.js/#TriggertheNativeSelectBox). Oh how I wish Bootstrap provided this option!
The only downside to this is that it adds another layer of complexity into a solution, and additional work to ensure compatibility with all other plug-ins as they get upgraded/patched over time. I'm also not sure about Bootstrap 3 compatibility. But, this may be a good solution to ensure a consistent look across browsers and OS's.
I'm sure -webkit-appearance:none does the trick for Chrome and Safari.
EDIT : -moz-appearance: none should now work as well on Firefox.
This is the normal behavior, and it's caused by the default <select> style under Firefox : you can't set line-height, then you need to play on padding when you want to have a customized <select>.
Example, with results under Firefox 25 / Chrome 31 / IE 10 :
<select>
<option>Default</option>
<option>Default</option>
<option>Default</option>
</select>
<select class="form-control">
<option>Bootstrap</option>
<option>Bootstrap</option>
<option>Bootstrap</option>
</select>
<select class="form-control custom">
<option>Custom</option>
<option>Custom</option>
<option>Custom</option>
</select>
select.custom {
padding: 0px;
}
Bootply
This is easy. You just need to put inside .form-control this:
.form-control{
-webkit-appearance:none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
}
This will remove browser's appearance and allow your CSS.
With Bootstrap 4+, you can simply add the class custom-select for your select inputs to drop the browser-specific styling and keep the arrow icons.
Documentation Here: Bootstrap 4 Custom Forms Select Menu
I found two potential ways of solving this specific problem:
Use Chosen
Target mozilla browsers using #-moz-document url-prefix() like so:
#-moz-document url-prefix() {
select {
padding: 5px;
}
}
We have been using the plugin bootstrap-select for Bootstrap for dtyling selects. Really works well and has lots of interesting additional features. I can recommend it for sure.
I am using Chosen.
Look at: http://harvesthq.github.io/chosen/
It works on Firefox, Chrome, IE and Safari with the same style. But not on Mobile Devices.
You can use jquery.chosen or bootstrap-select to add style to your buttons.Both work great. Caveat for Using Chosen or bootstrap-select: they both hide the original select and add in their own div with its own ID. If you are using jquery.validate along with this, for instance, it wont find the original select to do its validation on because it has been renamed.

Remove dotted outline from range input element in Firefox

Firefox, since version 23, natively supports the <input type="range"> element, but I couldn’t figure out how to remove the dotted outline. The following CSS has no effect:
input[type='range'],
input[type='range']:focus,
input[type='range']:active,
input[type='range']::-moz-focus-inner,
input[type='range']:-moz-focusring {
border: 0;
outline: none;
}
Does anyone have any idea how to fix this issue in Firefox?
Example: https://jsfiddle.net/pF37g/
Unfortunately, you can't! (update; you now can)
It's a bug in Firefox and there is no work-around to fix this besides from fixing the source base itself (see below).
Also see Jonathan Watt's blog (who is working on this):
Known issues:
the default CSS styled appearance still needs work, and native theming (giving the slider the appearance of the operating system's
theme) is still to come ...
In a reply to a comment in his blog about this very same issue he states:
Right now you can't - sorry. I've filed bug 932410 to make that
possible.
At the moment of writing there appear to be no progress on this and it's not known when a official fix will be available.
Update
Since this answer was posted the bug has been fixed. You can now use (as stated in other answers, but I include it here for completeness):
input[type=range]::-moz-focus-outer {
border: 0;
}
It can be done with new version of Firefox. As stated here, this bug is fixed. So it is possible to hide outer dotted border. To do so, set ::-moz-focus-outer's border to 0, like this:
input[type=range]::-moz-focus-outer {
border: 0;
}
Here is working example: http://jsfiddle.net/n2dsc/1/
In webkit browsers outer line will appear if -webkit-appearance: none; is set. To remove it, just set :focus's outline to none, like this:
input[type=range]:focus {
outline: none;
}
Here is working example: http://jsfiddle.net/8b5Mm/1/
As Ken already pointed out, there is no way to remove the outline. However, there is a work-around to "hide" the outline if you know the background-color of the parent element. Assuming a white background the following CSS would hide the dotted outline:
input[type=range] {
border: 1px solid white;
outline: 2px solid white;
outline-offset: -1px;
}
Your updated example: http://jsfiddle.net/9fVdd/15/
If you can settle for a wrapping element (it's likely you already have a wrapping LI or P), you can use FireFox-only CSS to position the input out of view and reposition the track/thumb in view.
Note 1 - don't try to use translateX - I think FireFox uses that to actually slide the thumb - so stick with translateY
Note 2 - Be sure to test with keyboard navigation. You should only move the input by the smallest amount possible to get the dotted lines out of sight. If you position it waaay far away (translateY(-1000em)) - then you will break usability for keyboard navigation.
Here ya go:
HTML
<span class="range-wrap"><input type="range" /></span>
CSS
.range-wrap {
overflow: hidden;
}
input[type='range'] {
-moz-transform: translateY(-3em);
}
input[type='range']::-moz-range-track {
-moz-transform: translateY(3em)
}
input[type='range']::-moz-range-thumb {
-moz-transform: translateY(3em);
}
http://jsfiddle.net/pF37g/98/
Dotted outline is not an issue, it's browser's way to show the input element is selected. What you can do is set tabIndex to -1 which will prevent your input element from taking focus on tab and, consequently, from having the outline:
<input class="size" type="range" tabIndex="-1" name="size" min="1" max="6" value="6"></input>
But after doing this you will lose some keyboard accessibility. It is better to have input element keyboard accessible.
Here is the fiddle: http://jsfiddle.net/pF37g/14/
If any custom styling is applied to input[type='range'] then Firefox use a different model (beta) to render the range input.
You can see the 2 different models here:
http://jsfiddle.net/pF37g/75/
Currently I do not believe it is currently possible to have a custom CSS styled input range box in Firefox to adhere to outline: 0; as of Firefox 27.0
To make it complete: The Bug has been fixed and now it's working with:
input[type=range]::-moz-focus-outer { border: 0; }
to remove all outlines from all input-tags use:
input::-moz-focus-inner, input::-moz-focus-outer { border: none; }
source: https://bugzilla.mozilla.org/show_bug.cgi?id=932410#c7
You can not. It seams to be a bug in Firefox.
It makes two outlines for the range element. One you can influence by css setting and a second, which is resistant against any manipulation.
I set the outline visible to show the issues:
input[type='range']:focus {
outline: 5px solid green;
}
Here you can see it:
http://jsfiddle.net/pF37g/97/
I have little research in config section of mozilla add this too
:-moz-any-link:focus {
outline: none;
}
a, a:active, a:visited, a:hover {
outline: 0;
}
then
:focus {
outline: none;
}
then
::-moz-focus-inner {
border: 0;
}
Here comes the solution
:focus {
outline:none;
}
::-moz-focus-inner {
border:0;
}

CSS Tooltips rendering problem in IE7+

I have tooptips show up when hovering over a link. These tooltips show filtering options for column headers. A tooltip contains text, a drop down list or a text box. In Firefox and Chrome the CSS works fine, however in IE7+ there are problems.
The tooltip appears over top all other objects on the page (as it's supposed to) except the original anchor link and image that you hover over. These get rendered over top the tooltip and it's contents.
The tooltip, when containing a dropdown list, disappears when the mouse cursor opens the drop down list and moves onto the DDL's listing box. I'm assuming that when the cursor moves over the list, it no longer is hovering over the tooltip, and it closes. IE has problems with telling the tooltip that when hovering over the DDL's list, that its actually hovering over the tooltip itself.
My CSS is very straight forward:
ul li a:hover { background: #88f; border-style: none; }
.tooltip{
z-index:25;
border: none;
color: inherit;
}
.tooltip:hover { z-index:25; position:relative;}
.tooltip span.tooltip_actual { display: none; }
.tooltip:hover span.tooltip_actual {
display:block;
position:absolute;
top:-1em; left: -42em; width: 40em;
border:1px solid #000;
background-color: #fff; color:#000;
text-align: left; padding: 1em;
}
Has anyone run into this issue before and is there a work around?
EDIT: this is the tooltip bug:
EDIT #2: Here is an example of my code: http://jsfiddle.net/NAXrc/
IE7 has known bugs with z-index.
If you can provide a test case, I can probably give you a better answer.
Otherwise, all I can do is point you to these resources:
http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/
IE 6 & IE 7 Z-Index Problem
IE7 Z-Index Layering Issues
http://richa.avasthi.name/blogs/tepumpkin/2008/01/11/ie7-lessons-learned/
however in IE7+ there are problems.
These problems should not exist in IE8/9. Is your page not using IE8/9 Standards Mode?
If your page is using Compatibility Mode (which emulates IE7) or Quirks Mode, that would explain why versions newer than 7 are also exhibiting the problem.

Resources