Select box's text strangely large in Firefox - css

In Safari, Chrome, and Opera a <select> box with a size of 20px looks like this:
But in Firefox, however, it looks like this:
Does anyone know why this is happening or how to fix it? Thanks!
EDIT: Here's a Fiddle so you can test it yourself.
EDIT2: This appears the be a Mac OS X problem, as someone with Windows did not see it.

I would suggest using em it will give you more standard across all browsers. 20px = 1.25em
Here are other options to chose from

You can turn off the default styling for select boxes in webkit and Firefox with these lines:
select {
-webkit-appearance: none;
-moz-appearance: none;
}
However, it's a finicky and non-standard solution. The font-size will change, but you'll lose all the other stuff, too, including the arrows.
Select boxes are notoriously difficult to style. There are some great third-party libraries like Selectize, Chosen, or select2, which actually replace the select element with a style-able DOM tree and use events to manipulate the select behind the scenes. You may find these easier to use.

Related

when trying to use ms-clear on element it doesnt work

I have a button
<button class="close"></button>
With this css
button.close {
font-size: 14px;
}
button.close::-ms-clear {
display: none;
}
But i cant make the ms clear work. What is wrong?
from the developer.mozilla.org
Non-standard
This feature is non-standard and is not on a standards
track. Do not use it on production sites facing the Web: it will not
work for every user. There may also be large incompatibilities between
implementations and the behavior may change in the future.
-ms-clear can only be applied on an input with type text. It is non-standard and only works in IE 10, 11 and Edge.
This pseudo-element is used to modify a little button which is visible by default to clear input boxes. You can see it working here, if you have an edge browser. Just click into the textbox and write something and a little cross will appear on the right side of the input box.

Firefox ignores outline and focus styles on select elements when using Tab

Context
Firefox 14 (and 13); specific CSS styles being ignored under certain conditions
The Problem
Using the following CSS:
*
{
outline:none;
-moz-outline:none;
-moz-user-focus:ignore;
}
JSFiddle
Firefox 14 (and 13) ignore these styles when using Tab to switch between select elements. Clicking these elements after using Tab still displays the outline.
Notes
Specifically styling select instead of * has no effect.
This only occurs with select elements.
The Question
Is this a bug or intended behavior?
Are there any other CSS styles that need to be used to prevent the outline from appearing indefinitely?
This is a known bug which has sparked several Stackoverflow discussions. From what I have read, Mozilla have deemed that CSS is the wrong place to handle this element behaviour, and have opted instead to handle it by other means. At this time the only solution is to either use tabindex="-1" or to set the element to display as something else, and restyle the look and feel of a droplist — but be warned, this opens a can of worms in itself.
If you do opt to do this, I have had success in the past with the following kludge:
select {
appearance: normal;
-webkit-appearance: none;
-moz-appearance: radio-container; /* renders text within select, without arrow chrome */
}
Appearance tells the browser to display the element as something else, but this is inconsistent from vendor to vendor. appearance: normal; is the spec, whilst webkit replaces normal with none. -moz-appearance: radio-container; has been the only way I have found to display the text within the chosen select option, whilst removing the arrow chrome for a fully customised droplist. However, try experimenting with the available options until you find something that works and doesn't add the focus ring you wish to customise. Internet Explorer will require further kludge to bend the select to your needs. Entirely possible, but out of scope for this question and answer.
So far the only way I've found to overcome it is to set the tabindex='-1' (see fiddle) which, of course, takes the element completely out of the tab selection chain. That would not be good for user interface, and my guess is not exactly what you desire (I assume you want to keep tab accessibility but just do your own styling for highlighting).
Another solution is to set outline: none and set a box-shadow. For example:
.my_elements:focus
{
outline: none;
box-shadow: 0 0 3px 0px red;
}
Use
*:-moz-focusring {
outline: 2px solid blue;
}
will give you similiar to chrome
Also, if using mac, you also need to enable this:
How to allow keyboard focus of links in Firefox?

text-indent in SELECT elements no longer working in Chrome

http://jsfiddle.net/PFBqq/
On Windows XP, it's working fine in Firefox 3.6 and Safari 4, but it doesn't seem to be working in the latest version (13) of Chrome. Unless I'm mistaken, I remember it used to work?
Anyone have a hack/fix for this?
The select and option elements are hardly stylable and have a lot of issues in different browsers.
So, if you really want the indentation the only way to do it without writing custom select is adding s to the start of the lines like this.
However, there are downsides of this hack: with the spaces at the start of options you couldn't jump to the desired options from the keyboard.
It will work if you specify line-height
select{
height:34px; //optional
line-height: 34px;
text-indent: 20px;
}
Please look at this fiddle
Hope it solves your issue

Form Field Outlining

I'm trying to remove the blue "halo" outline that form elements have in Firefox on OS X. Using CSS, I can remove the halo in Safari on OS X, via:
input {
outline: none;
}
But this seems to have no effect in Firefox, nor does the -moz-outline property.
Another option, that takes care of all of the 'halo' is this:
*:focus {outline: none;}
I guess you could add an !important if you wished, but I haven't run into the need yet.
:focus {outline:none;}
::-moz-focus-inner {border:0;}
I'm going out on a limb since I don't have OSX to test it... but does removing the border work?
input {
border: 0;
}
I believe the style of all the form elements are stored in the forms.css file. In OS X, I think it is located here:
/Applications/Firefox.app/Contents/MacOS/res/forms.css
You may want to browse through that file and see if there is any obvious CSS that is affecting the appearance you are seeing. For example, on Windows the input element has -moz-appearance: textfield;, which I couldn't find any documentation on, so perhaps there is some "native" -moz-* style on those fields that is controlling the glow, something you could possibly override.
The other thing to try might be to override everything in that file by changing the input definitions to input2 or something (after making a copy of course). Then you can see if you can get the glow to stop at all by manipulating the default CSS.
Once you've determined you can make it stop (if you can), you can add styles back in a bit at a time until you find the one that causes the effect you don't want. You can probably speed up that process by eliminating styles from your testing that obviously aren't related (e.g. - line-height: normal !important; is almost certainly not responsible for a blue glow around the fields).
Maybe you have an active user style sheet in your machine creating this behaviour. Some add-ons do this (to make the focus more obvious).
Look into the firefox's chome forder (in your user files)
Alternatively try with
input {outline: none!important;}
Also
The Stylish plugin has a style for this, maybe you have it installed?
There are greasemonkey script that do this. If you have it installed, disable it
They both take precedence over the !important attribute.
So: you have several places to look into
* User stylesheets
* Stylysh
* greasemonkey
* anothes add-on
One of those must be forcing the outline
I went through the various suggestions made here, but none seemed to be able to fully address the problem. By defining a custom border style, i.e.
border: 1px solid #000;
I'm able to get rid of the focus halo, but this obviously alters the look of the input element. border-style: inset; seems to most closely resemble the "native" look, but it's still not quite right, so as far as I can tell right now, you can either suppress the halo, or have a natural looking input.
I believe this is what you are looking for:
input:focus { outline: none; }

Input background colour destroys styling?

I am creating a form which is validated under jQuery Validation. I want to apply a light-red background colour to inputs which are invalid and need to be corrected.
When I apply background-color: #FFCCCC; to the input, the attractive styling seems to be removed and a hard border replaces it. For example, with a text input in Firefox:
Styled and unstyled text input http://liranuna.com/strager/b/textbox-difference.png
(Live demo)
This occurs with several browsers. It also occurs if I set any background other than #FFFFFF.
Is there a way to preserve styling while applying a background colour?
I am open to Javascript solutions which emulate the style somehow.
Sorry - any sort of styling on input elements tends to destroy their OS/browser defaults. The default inputs are rendered in an entirely different way - it's not like they're coded into the browser as CSS styles, unfortunately.
The best thing to do here is, rather than try to make your red-background inputs emulate normal ones, create your own attractive styling! If you like those light borders, use border: 1px #ccc solid. If you like round corners, take advantage of border-radius and -moz-border-radius - for those who are on the edge of browser development, they'll have 'em. For those who aren't, they won't notice the difference.
In short, don't try to make the inputs fit in with the OS environment, but rather style them to your own site's look and feel. This will create better design for your website overall :)
I'd say the default (Windows 2000) look of the controls is easier to implement for the browser vendors. A browser has to draw everything itself, including any controls. That they look native in their default style is just a little convenience for the user but without something really fancy (and heavyweight) like WPF it quickly becomes unwieldly to draw the control correctly with visual styles of the OS and CSS applied.
The exact style is also dependent on the OS and therefore a solution giving you exactly one look might not be what most visitors of your site want. Then again, using only CSS you can achieve The One Look™. If that just happens to look like the native one on a specific OS, well, then so be it :-)
What you're looking for might probably be emulated a little by using a light-gray border and on hover/focus a light blue one, emulating the Aero look of Vista and Windows 7.
Here the browser is using its default styling.
I would suggest adding something like the following CSS to BOTH inputs, then they will look consistent.
border: solid 1px #ccc;
Short answer: no.
Browsers and form controls is without doubt the most inconsistent part of CSS. All I can suggest is to use a 1px border on input fields, as most browsers use something similar to this. CSS3 rounded corners should also work in a few browsers.
input.text {
border: 1px solid #ccc;
background-color: #fcc;
border-radius: 4px;
-moz-border-radius: 4px;
}
You will find this page at 456 Berea Street interesting. It showcases how each browser applies different styles on text boxes.
Check out what styles the normal input field is getting for border. And apply that to the error one also.
Change your HTML to be like this:
<p><input type="text" value="text" style="border:1px solid #999999;" /></p>
<p><input type="text" value="text" style="background-color: #FFDDDD;border:1px solid #999999;" /></p>
Edit: If you want it to look consistent across all browsers and not only slightly rounded in Mozilla then you'll have to do a lot more work. Here's a link that will show you how to completely override the textbox style.

Resources