Custom select element with only CSS - html

I'm trying to customize a select element with only CSS, found this:
<div class="cs_div">
<select>
<option>Option 1</option>
<option>Option 2</option>
</select>
</div>
css:
.cs_div {
border: 1px solid #ccc;
border-radius: 3px;
overflow: hidden;
background: #fafafa url("../images/select.png") no-repeat;
width: 190px;
}
.cs_div select {
margin: 0;
padding: 5px 8px;
width: 215px;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
}
.cs_div select:focus {
outline: none;
}
works great, but something on main stylesheet of site adds a "blank space" at bottom of div, in chrome, in firefox this doesn't occur.
chrome:
firefox:
already tried padding-bottom: 0; margin-bottom: 0; but not works...
here is a test site with the custom select element: http://eliterosa.bl.ee/activity/

Your question is a bit vague but you may be referring to the vertical alignment of the now inline-block div. You just need to use vertical-align: middle; to div#activity-filter-by-outer...
#activity-filter-by-outer { display: inline-block; vertical-align: middle; }
Now that you made the div an inline block it takes up line-height much like other inline elements.
See screen shot:

Just figured out a way to remove the select arrow from Firefox. The trick is
to use a mix of -prefix-appearance, text-indent and text-overflow.
select {
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
}
It's pure CSS and requires no extra markup. Tested on Ubuntu and Linux,
latest versions.
Live example: http://jsfiddle.net/4WVZW/
by: Ricardo Fuhrmann

Related

How to remove blue background for focus/hover on select/option dropdown

How do i remove the blue background when active on an option and hovering on an option with my select dropdown.
Here is a screenshot of what i mean:
I have tried every css rule i could thin off and even search the internet, including here but nothing is working
.language {
float: right;
margin-top: -45px;
padding-right: 25px;
}
.language select {
width: 180px;
border: none;
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
cursor: pointer;
}
.language select::-ms-expand {
display: none;
}
.language option {
background-color: #000;
color: #fff;
}
.language option:hover {
background-color: #000;
color: #fff;
}
.language-selector::before {
font-family: "Font Awesome 5 Free";
content: "\f0ac";
visibility: visible;
font-weight: 900;
position: relative;
float: left;
margin-left: 1690px;
margin-top: -53px;
}
<div class="language">
<select>
<option value="">English</option>
<option value="">Deutsch</option>
</select>
</div>
Well, you can't. This is set by the OS. Sorry :/
Try this
:focus {outline:0 !important;}
and this
:hover {outline:0 !important;}
If this is not working try on ur own css style !importent this will overwrite all the normall css
Good luck :)
Usually you'd use background: transparent but you have to tell us the rule that's setting the blue color or if it's the OS/browser as someone else mentioned, tell us which OS/browser. Dropdown attributes can't always be styled as many are set by the browser (see the diff between them in Firefox and Chrome). The solution for complete style control is unfortunately to create your own dropdowns using a trigger and list of items you toggle visibility and handle the user's selection.
hi It's happend for me and this is mt solution {background: transparent !important;}

Text input and submit input elements have different height in firefox

The code:
<input class="text" type="text" value="text"><input class="submit" type="submit" value="submit">
with styling:
.text, .submit {
outline: none;
border: none;
padding: none;
margin: none;
background: red;
padding: 3px;
box-sizing:border-box;
}
(https://jsfiddle.net/citizenfive/04camn42/)
creates 2 input elements with different heights (submit is larger by ~1px).
The code works fine on Chrome. Is there a way to solve this for Firefox?
All browsers have differences between default behaviours and styles, but firefox is more flexible with S.O. and form elements are controlled by default by the operating system.
The solution is remove padding or use height with EM meassures.
Remove padding:
https://jsfiddle.net/04camn42/2/
.class { padding: 0 }
Using EM height:
https://jsfiddle.net/04camn42/3/
.class {
height: 1.5em
}
IF you use EM you don't worry about responsiveness and user choices.
Removed padding and added height, this works fine in Chrome and Firefox but I don't know whether this fix is fine for you.
New css,
.text, .submit {
outline: none;
border: none;
padding: none;
margin: none;
background: red;
/* padding: 3px; */
box-sizing: border-box;
height: 23px;
}
In order to remove all padding and borders from buttons and inputs for Firefox this handy little CSS snippet will help you out.
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
Also, what's been suggested by the other posters: use box-sizing: border-box; on all form elements to make them behave in all browsers (apart from Firefox).
.text, .submit {
outline: none;
border: none;
padding: none;
margin: none;
background: red;
padding: 3px;
box-sizing:border-box;
-moz-box-sizing:border-box;
}
see in i

How to style the text of a select box except the options

I need to style the text of a select box, not the list of options. When I add a padding to the select box, this is applied to the list of options, as well. Look at this image:
The icon is a pseudo-element ::before of the div. (I use a div because the select box doesn't work with pseudo-elements).
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
cursor: pointer;
display: inline-block;
height: 35px;
padding: 7px;
padding-left: 30px;
}
select::-ms-expand {
display: none;
}
.select-wrapper {
display: inline-block;
float: right;
position: relative;
}
.select-wrapper:before {
color: #ccc;
content: "\f0c9";
display: inline-block;
font: 16px "FontAwesome";
padding: 9px;
pointer-events: none;
position: absolute;
}
<div class="select-wrapper">
<select class="turnintodropdown">
<option selected="selected" value="">Menu</option>
<option value="http://localhost/wpdev/sample-page/"> Sample Page</option>
<!-- And more options... -->
</select>
</div>
I don't want that the list of options inherits the padding of the main select.
It's hard to tell without knowing the visual styles (FontAwesome?) you have applied in the picture. However, you can use the HTML option element as a CSS Selector:
.select-wrapper .turnintodropdown option {
padding: 0;
}
Alternatively, you can give all your options a class, and style them using that class as well.
Note: styling the padding property of the option element does not currently work in any browser except Firefox, although you can style things like color and background-color in all browsers, including IE11 (I don't have the ability to test older versions of IE).
A Chrome bug report exists for this, but it has been punted down the line for five years already, so I wouldn't hope for a fix soon.

remove default select box arrow in firefox

I have to remove the default select box arrow in firefox
I used the below code
-webkit-appearance: none;
-moz-appearance:none;
background: rgba(0,0,0,0);
its working good in chrome. but its not working in firefox.
Update: this was fixed in Firefox v35. See the full gist for details.
Just figured out how to remove the select arrow from Firefox. The trick is to use a mix of -prefix-appearance, text-indent and text-overflow. It is pure CSS and requires no extra markup.
select {
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
}
Tested on Windows 8, Ubuntu and Mac, latest versions of Firefox.
Live example: http://jsfiddle.net/joaocunha/RUEbp/1/
More on the subject: https://gist.github.com/joaocunha/6273016
Handling this can be done in following way :
1) your html might be like this:
<div class="select-box">
<select>
<option>Mozilla Firefox</option>
<option>Google Chrome</option>
<option>Apple Safari</option>
<option>Internet Explorer</option>
</select>
</div>
2)your css should be like this:
.select-box select{width:100%}
/* For Microsoft IE */
select::-ms-expand { display: none; }
/* For Webkit based browsers Google Chrome, Apple Safari and latest Gecko browsers */
select{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
Try it. I hope this helps. Working on latest versions of firefox, chrome, ie and safari, if not on all versions. But do check on all versions of all browsers.
I think there's no simple way of doing it in Firefox, especially for the Linux and Mac OS version.
Change the opacity of the select box to 0, and then use a div/span to contain the select box. After that, add some styles on that container. This is a not-recommended workaround, and it's too costly if we want to only change the style of a select box. However, it solves the problem anyway. Hope this helps. =)
Original:
<select>
<option>Value 1</option>
<option>Value 2</option>
</select>
New:
<span class="select-container">
<select>
<option>Value 1</option>
<option>Value 2</option>
</select>
</span>
Style:
.select-container {
width: 100px;
height: 30px;
position: relative;
border: 1px solid #ccc;
background: url("path of the arrow image") no-repeat right center;
background-size: 25px;
}
select {
position: absolute;
opacity: 0;
outline: 0;
}
Then, add some Javascript to display the selected value in the container.
Simple way to remove drop down arrow from select in Chrome and Mozilla
select {
/*for firefox*/
-moz-appearance: none;
/*for chrome*/
-webkit-appearance:none;
}
/*for IE10*/
select::-ms-expand {
display: none;
}
<select>
<option>India</option >
<option>India</option >
<option>India</option >
</select>
gcyrillus suggest a neat solution for this issue in this website.
http://css-tricks.com/forums/topic/remove-select-arrow-for-chrome-and-firefox/
$(document).ready(function(){
$(".selsect_class").each(function(){
$(this).after("<span class='select_holder'></span>");
});
$(".selsect_class").change(function(){
var selectedOption = $(this).find(":selected").text();
$(this).next(".select_holder").text(selectedOption);
}).trigger('change');
})
.selsect_id{
background: url("http://a1lrsrealtyservices.com/demo/ot-select.png") no-repeat scroll right center #fff;
border: 1px solid #ccc;
border-radius: 2px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05) inset;
box-sizing: border-box;
display: block;
font-size: 12px;
height: 29px;
margin: 0 5px 5px 0;
width: 100%;
}
.selsect_class{
cursor: pointer;
font-size: 14px;
height: 29px;
opacity: 0;
position: relative;
width: inherit;
z-index: 4;
}
.selsect_class option{padding: 3px 15px;}
.select_holder{position: absolute;left: 30px;top: 5px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="selsect_id">
<select class="selsect_class">
<option value="">- Choose One -</option>
<option value="1">jillur</option>
<option value="2">korim</option>
<option value="3">rohim</option>
<option value="4">Uncategorized</option>
</select>
</div>
preview image

"-webkit-appearance: none;" Firefox equivalent?

I would like to know if there is anything equivalent to: -webkit-appearance: none; for Firefox?
What I want to achieve:
<select ...>
<option>...</option>
<more option>
</select>
The -moz-appearance CSS property is
used in Gecko (Firefox) to display an
element using a platform-native
styling based on the operating
system's theme.
Source:
Mozilla
-moz-appearance:none with <select> still shows a dropdown arrow on Firefox.
See this bug report for more information: https://bugzilla.mozilla.org/show_bug.cgi?id=649849
https://developer.mozilla.org/en/CSS/-moz-appearance
Try this.. It works
select{
-moz-appearance: none;
text-overflow: '';
text-indent: 0.1px;
}
Tested on Windows 8, Ubuntu and Mac, latest versions of Firefox.
Live example: http://jsfiddle.net/gaurangkathiriya/z3JTh/
If you want a select looking like a button in Firefox, use:
select { -moz-appearance: button; }
Like here: http://jsfiddle.net/SsTHA/
Try this...for me it's working on Firefox:
select {
padding: 0px 0px 0px 5px;
border-radius: 0px;
webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
-webkit-appearance: none;
background: #ffffff url(../images/small-arrow-down.png) 62px 7px no-repeat;
padding: 1px 20px 1px 3px;
cursor: pointer;
border-radius: 2px;
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
}
Here is the code for Firefox, Chrome, Safari, and Internet Explorer (Internet Explorer 10 and up).
Just add a small down arrow PNG image for your select and it's all set.
My arrow is 30x30, but set it to your specifications.
.yourClass select{
overflow: none;
background-color: #ffffff;
-webkit-appearance: none;
background-image: url(../images/icons/downArrow.png);
background-repeat: no-repeat;
background-position: right;
cursor: pointer;
}
/* Fall back for Internet Explorer 10 and later */
.yourClass select::-ms-expand {
display: none;
}