IE & Firefox - custom drop down could not remove native arrows - css

I'm trying create a custom drop down control and I need to hide the arrows from the native controls. I'm using the following CSS, which is working for Chrome and Safari, but not in Mozilla and IE.
select.desktopDropDown
{
appearance: none;
-moz-appearance:none; /* Firefox */
-webkit-appearance:none; /* Safari and Chrome */
}
Here is a [jsfiddle][1].

Use this it will work but with IE10+ and for FF :
Your css should look like this:
select.desktopDropDown::-ms-expand {
display: none;
}
More about ::ms-expand.
Then for the rest :
select.desktopDropDown {
outline : none;
overflow : hidden;
text-indent : 0.01px;
text-overflow : '';
background : url("../img/assets/arrow.png") no-repeat right #666;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
}
Note: I hardcoded path "../img/assets/arrow.png" as background.
This should work good for you in IE, Firefox and Opera .

Bare-bones examples:
For I.E:
select::-ms-expand {
display: none;
}
For Firefox:
select {
-moz-appearance: none;
appearance: none;
text-overflow: ''; /* this is important! */
}

For Fx I use -moz-appearance: checkbox-container which works nicely.
So putting it all together the following should be sufficient for you:
select.desktopDropDown {
appearance: none;
-webkit-appearance: none;
-moz-appearance: checkbox-container;
border-style: none;
}
select.desktopDropDown::-ms-expand {
display: none;
}

In fact this trick is mainly required for IE10+ where the arrows are in the Metro style of Windows 8, even on Windows 7. Though Windows 8 users must be used to the style cause it's used through the OS. Anyway, I'd recommend instead of using:
display: none;
To use:
visibility: hidden;
Because, at least in IE, the former causes the blue line of the selected item to overlay the dropdown arrow when the select is focused, while the latter does not.

we can create custom by using css. tested on IE10, Mozilla and chrome borwser...
Working Example as below :
.customSelect {
position: relative;
}
/* IE11 hide hacks*/
select::-ms-expand {
display: none;
}
.customSelect:after {
content: '<>';
font: 17px "Consolas", monospace;
color: #333;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
right: 11px;
/*Adjust for position however you want*/
top: 18px;
padding: 0 0 2px;
border-bottom: 1px solid #999;
/*left line */
position: absolute;
pointer-events: none;
}
.customSelect select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Add some styling */
display: block;
width: 100%;
height: 50px;
float: none;
margin: 5px 0px;
padding: 0px 24px;
font-size: 16px;
line-height: 1.75;
color: #333;
background-color: #ffffff;
background-image: none;
border: 1px solid #cccccc;
-ms-word-break: normal;
word-break: normal;
}
<div class="customSelect">
<label>
<select>
<option selected> Select Box </option>
<option>Option 1</option>
<option>Option 2</option>
<option>Last long option</option>
</select>
</label>
</div>

Related

scss hide select arrow, appearance & -webkit-appearance: none; not working

I need to hide the dropdown arrows on my select boxes when they are disable. From every thing I have read, this should work?
select.btn-underline-primary {
box-shadow: none !important;
padding-left: 0;
color: $dark !important;
option {
border: none;
}
&:disabled {
border-bottom-color: transparent;
&::-ms-expand {
display: none;
}
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
}
The problem is that applying display: none to the ::ms-expand only hides the dropdown for Internet Explorer 10 and 11. If you additionally want to hide it for Firefox / Chrome , you'll need to apply -moz-appearance: none and -webkit-appearance: none to the select respectively.
Note that :disabled is an attribute of the select element itself, and does not create a separate pseudo-class in the DOM. As such, you'll need a separate selector:
select.btn-underline-primary:disabled
Which combined with the rest of the code looks like:
select.btn-underline-primary {
box-shadow: none !important;
padding-left: 0;
color: $dark !important;
option {
border: none;
}
&::-ms-expand {
display: none; /* Hide dropdown in IE 10 & 11 */
}
}
select.btn-underline-primary:disabled {
border-bottom-color: transparent;
-moz-appearance: none; /* Hide dropdown in Firefox */
-webkit-appearance: none; /* Hide dropdown in Chrome */
}
This can be seen working on JSFiddle.

How can I change the background color of option from select tag?

I am trying to change the background colour for option from the select tag.
I tried select > option but it doesn't work.
My code below:
select {
width: 100%;
height: 32px;
background-image: url("images/2017_04_form_select.jpg");
padding-right: 25px;
/* Safari 3-4, iOS 1-3.2, Android 1.6- */
-webkit-border-radius: 0;
/* Firefox 1-3.6 */
-moz-border-radius: 0;
/* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
border-radius: 0;
background-repeat: no-repeat;
background-position: right center;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
border: 1px solid #bdb9bb;
margin-bottom: 20px;
}
select:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
select::-ms-expand {
display: none;
}
select>option {
background: #e8e4e6;
}
You just need to set a background-color for select option
select option {
background-color: red;
}
<select>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
Have you tried just select.option ?
Or just option ?

How to target IE for select tag styling

I am using select tag and the following is the css I used in order to hide the default Dropdown button that comes with element:
select,
input {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
}
It works on all browsers except IE. I tried using the expand option but also does not work.
select::-ms-expand{
display: none;
}
How can I hide the Dropdown of the select tag so that I can add an icon of my wish?
Thanks in advance
Wrap the select tag inside a div and do some adjustments. You will get the desired effect. see the snippet
select::-ms-expand {
display: none;
}
will work IE 10 and above, for IE 9 and below, we can simply do a trick by giving the wrapper less width than that of the select element. thus, the caret button will overflow the parent and become hidden.
.select{
width:80px;
overflow:hidden;
border: 1px solid #333;
padding: 0;
}
select::-ms-expand {
display: none;
}
.select select{
width: 120px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 6px 15px;
border: none;
background: transparent url("https://cdn2.iconfinder.com/data/icons/navigation-set-arrows-part-two/32/Arrow_Download-16.png") no-repeat 60px center;
outline: 0;
}
<div class="select">
<select>
<option value="1">Option</option>
<option value="2">Option</option>
<option value="3">Option</option>
</select>
</div>

child element doesn't fill button up

I want the inner element (slot in this case) to fill the button up. It works in chrome but doesn't in FireFox. I think there might be use user-agent styles in FireFox. I can't specify how wide the button is because I don't know it's size (not fixed).
jsbin link to play around:
http://jsbin.com/pucapoxizi/1/edit?html,css,output
What I've got so far:
HTML:
<button>
<slot>abc</slot>
</button>
CSS:
button {
border: 0;
padding: 0;
background: red;
}
slot {
width: 100%;
background: green;
}
Screenshots
FireFox:
Chrome:
You need to remove the extra padding for firefox button:
button::-moz-focus-inner {
padding: 0;
border: 0
}
you need to write css on top of a css reset stylesheet,for example a button reset css
button {
background: none;
border: 0;
color: inherit;
/* cursor: default; */
font: inherit;
line-height: normal;
overflow: visible;
padding: 0;
-webkit-appearance: button; /* for input */
-webkit-user-select: none; /* for button */
-moz-user-select: none;
-ms-user-select: none;
}
button::-moz-focus-inner {
border: 0;
padding: 0;
}

Remove all stylings (border, glow) from textarea

I want to remove the stylings from a textarea and leave it all white without any border or glow, if possible. I've tried with different stuff found here on SO, but nothing works (tried with FF and Chrome).
So, is it possible and if so how to do it?
What I've tried so far:
textarea#story {
// other stuff
-moz-appearance:none;
outline:0px none transparent;
}
textarea:focus, input:focus{
outline: 0;
}
*:focus {
outline: 0;
}
The glow effect is most-likely controlled by box-shadow. In addition to adding what Pavel said, you can add the box-shadow property for the different browser engines.
textarea {
border: none;
overflow: auto;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
resize: none; /*remove the resize handle on the bottom right*/
}
You may also try adding !important to prioritize this CSS.
If you want to remove EVERYTHING :
textarea {
border: none;
background-color: transparent;
resize: none;
outline: none;
}
try this:
textarea {
border-style: none;
border-color: Transparent;
overflow: auto;
outline: none;
}
jsbin: http://jsbin.com/orozon/2/
You want a minimal textarea with no borders, or resize-drag-icon.
Both when not selected and when focus.
It's easy but you'll need to update rows attribute via JS as newlines are added or removed during text input.
Here is the CSS
textarea, textarea:focus
{
font-family: "roboto","Helvetica Neue",Helvetica,Arial,sans-serif; /* make your choice */
font-size: 11px; /* make your choice */
border: none;
background: transparent;
-webkit-appearance: none;
-moz-apperarance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
outline: none;
padding: 0px;
resize: none;
width: 100%;
overflow: hidden;
-webkit-box-shadow: none;
-moz-box-shadow: none;
-ms-box-shadow: none;
-o-box-shadow: none;
box-shadow: none;
}
 
in order to keep things working as expected (looking good) you have to programmatically set/update textarea's attribute rows to the count of \r\n in the the textarea contents plus 1 when the contents is set and when it's updated (user input / other)
 

Resources