HTML select dropdown arrow style - html

How to get the select dropdown arrow styled like shown in the image below.
<select>
<option>Select Any</option>
<option>Option 1</option>
<option>Option 2</option>
</select>

Try this:
HTML:
<div class="styled-select slate">
<select>
<option>Here is the first option</option>
<option>The second option</option>
<option>The third option</option>
</select>
</div>
CSS:
div { margin: 20px; }
.styled-select {
height: 29px;
overflow: hidden;
width: 240px;
}
.styled-select select {
background: transparent;
border: none;
font-size: 14px;
height: 29px;
padding: 5px; /* If you add too much padding here, the options won't show in IE */
width: 268px;
}
.styled-select.slate {
background: url(http://i.stack.imgur.com/8CVVr.png) no-repeat right center;
height: 34px;
width: 240px;
}

How about this... Just set that image to Select's background.
.select-style {
width: 268px;
line-height: 1;
border: 0;
overflow: hidden;
height: 34px;
position:relative;
background:#fff;
}
.select-style>select{
-webkit-appearance: none;
appearance:none;
-moz-appearance:none;
width:100%;
background:none;
background:transparent;
border:none;
outline:none;
cursor:pointer;
padding:7px 10px;
}
.select-style>span{
position:absolute;
bottom: 0;
right: 0;
height: 0;
width: 0;
cursor:pointer;
border-right: 10px solid #ff0099;
border-bottom: 10px solid #ff0099;
border-left: 10px solid transparent;
border-top: 10px solid transparent;
}
select::-ms-expand {
display: none;
}
<div class="select-style">
<select>
<option>Select Any</option>
<option>Option 1</option>
<option>Option 2</option>
</select>
<span></span>
</div>
Fiddle: https://jsfiddle.net/sank8893/bhy9do60/9/

As others have mentioned you can hide the default select arrow by appearance property and apply your own style.
To support lower versions of IE(i haven't consider below 9) as appearance property won't work even with ms prefix , you can use the below method to have common support.
Arrow made by css not an image.
$( "#sel_val" ).change(function() {
var option = $(this).find('option:selected').val();
$('#sel_txt').text(option);
});
.wrapper{width:250px;margin:10px auto;}
.sbx{
margin:0;
width:100%;
font-family:arial;
position:relative;
background-color:#eee;
}
.cus_selt:after{content:'';width:0;
height:0;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-top:10px solid #FD025F;
position:absolute;
bottom:-1px;
z-index:2;
right:-6px;
transform:rotate(-45deg);
}
.cus_selt{padding:20px;display:block;}
.styled {
float:left;
height: 56px;
margin: -58px 0 0;
opacity: 0;
width: 100%;
filter: alpha(opacity=0);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="sbx" id="yoe_fld">
<span class="cus_selt" id="sel_txt">Select a value*</span>
<select id="sel_val" class="styled">
<option>Select</option>
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
<option>option5</option>
<option>option6</option>
<option>option7</option>
</select>
</div>
</div>
Source link for custom select dropdown click
Source link for CSS arrow click

see here jsfiddle
first you need to remove the default styling of the select dropdown. to do that use
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
for IE use :
select::-ms-expand {
display: none;
}
then just apply your desired style, in this case with background-image
or you can use border to make a triangle and place it by using pseudo-elements like :before or :after .
select {
background:url("http://i.stack.imgur.com/8CVVr.png") no-repeat scroll right bottom;
background-size:contain;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding:5px 10px;
}

Related

Add padding to select, but not option tags

I have a simple select dropdown menu with a significant amount of padding-left and padding-right:
If you click the select input, you'll notice the option tags also have the same amount of padding-left and padding-right applied. However, I want the padding to only apply to the select tag, but not the option tags (i.e. no padding for the option tags).
How can I do this?
select {
width: 400px;
background: lightgray;
padding: 12px 48px;
}
<select>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>
</select>
From what I know the select box and the dropdown get rendered by the browser engine. This means they are not changeable.
So the only solution is to use a framework (Because of this reason there are many outside) or build one by your own.
If you look in the developer console you will also see that most of the styles of the option element are inherited by the browser and greyed out.
Try This:
$(document).ready(function(){
$('.sel').click(function(){
$('ul').toggle();
})
$('li').click(function(){
$('.sel input[type=text]').val($(this).html());
$('ul').hide();
})
})
* {
box-sizing: border-box;
}
.wrapper {
width: 400px;
position: relative;
cursor: pointer;
}
.sel {
position: relative;
width: inherit;
border: 1px solid #000;
}
.sel input[type="text"]{
width: 100%;
background: lightgray;
padding: 12px 48px;
border-style: none;
outline: none;
cursor: pointer;
}
.sel span {
position: absolute;
right: 25px;
top: 10px;
}
ul {
padding: 0;
margin: 0;
list-style: none;
background: lightgray;
width: 100%;
display: none;
z-index: 999;
}
li {
padding: 10px 0;
}
li:hover {
background-color: skyblue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="wrapper">
<div class="sel">
<input type="text" readonly="readonly" value="Option1"><span>▼</span>
</div>
<ul>
<li>Option1</li>
<li>Option2</li>
<li>Option3</li>
</ul>
</div>

replace select dropdown arrow with fa-icon

I am trying to replace a select dropdown arrow with a fa-icon (chevron-circle-down) but I can only find that the background can be replaced with an image in the css file.I can add the icon over the select,but it won't be clickable.Any help how I use font icon in select dropdown list ?
as you can't use pseudo-elements on <select> you use them on a label instead.
using:
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
will hide the default down arrow the select has and instead you use the fa-chevron-circle-down icon with it's unicode \f13a as an :after pseudo-element applied to the label
it's not really a 'beautiful' solution, but it does the trick
let me know if it helps
see below snippet
label.wrap {
width:200px;
overflow: hidden;
height: 50px;
position: relative;
display: block;
border:2px solid blue;
}
select.dropdown{
height: 50px;
padding: 10px;
border: 0;
font-size: 15px;
width: 200px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
label.wrap:after {
content:"\f13a ";
font-family: FontAwesome;
color: #000;
position: absolute;
right: 0;
top: 18px;
z-index: 1;
width: 10%;
height: 100%;
pointer-events: none;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<label class="wrap">
<select class="dropdown">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</label>

How do I change the arrow in the select with Chosen plugin?

so i can't figure how i change the dropdown arrow, i need to change it to another arrow:
Original
How I want it to look like
I am using Chosen plugin, i don't know if that effects in general my edits on <select>.
Heres the php:
<div class="paistofill">
<select class="form-control bfh-countries chosen-select " data-country="PT">
<option value="PT">Portugal</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
(...)
</select>
The CSS:
select{
-webkit-appearence:none;
background-image:url("recursos/images/span/seta.png");
background-repeat:none;
background-position:right center;
}
I though this would do the trick. Nothing changed, what can I do?
JSFiddle
There is this class in chosen.css
.chosen-container-single .chosen-single div b {
display: block;
width: 100%;
height: 100%;
background: url('chosen-sprite.png') no-repeat 0px 2px;
}
With this image https://harvesthq.github.io/chosen/chosen-sprite.png
So change background to your image.
Try the below code.
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image: url("recursos/images/span/seta.png");
background-repeat: none;
background-position: right center;
}
Check this fiddle here
You have to make some changes in CSS and try to use a parent container for styling select as,
Your CSS,
select {
font-family: 'Hind Madurai','Segoe UI','Helvetica Neue', sans-serif;
background:#F9F9F9;
color:#111111;
border:1px solid #CCCCCC;
border-radius:5px;
padding: 8px 15px;
font-size:15px;
letter-spacing:0.05em;
width:300px;
margin: 0 0 20px 0;
max-width: 100%;
resize: none;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
.paistofill select {
-webkit-appearance: none;
-moz-appearance: none;
cursor: pointer;
background:url(https://s31.postimg.org/9rchnwbwr/down_arrow.png) no-repeat #F9F9F9;
background-position: 96% 12px;
text-indent: 0.01px;
text-overflow: "";
}
.paistofill select option {
background:#FFFFFF;
color:#111111;
}

Cannot remove outline/dotted border from Firefox select drop down [duplicate]

This question already has answers here:
Remove outline from select box in FF
(15 answers)
Closed 5 years ago.
I have a styled down down, but I cannot remove the dotted border when it is clicked in Firefox. I've used outline: none but it still doesn't work. Any ideas?
CSS:
.styled-select {
background: lightblue;
font-size: 20px;
height: 50px;
line-height: 50px;
position: relative;
border: 0 none !important;
outline: 1px none !important;
}
.styled-select select {
background: transparent;
border: 0;
border-radius: 0;
height: 50px;
line-height: 50px;
padding-top: 0; padding-bottom: 0;
width: 100%;
-webkit-appearance: none;
text-indent: 0.01px;
text-overflow: '';
border: 0 none !important;
outline: 1px none !important;
}
HTML:
<div class="styled-select">
<select id="select">
<option value="0">Option one</option>
<option value="1">Another option</option>
<option value="2">Select this</option>
<option value="3">Something good</option>
<option value="4">Something bad</option>
</select>
</div>
Please see this jsFiddle.
Found my answer here: https://stackoverflow.com/a/18853002/1261316
It wasn't set as the correct answer, but it worked perfectly for me:
select:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
select {
background: transparent;
}
This will help you. Place it on top of your style sheet.
/**
* Address `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline:0;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}

CSS Select box arrow style

I want to remove the default arrow from the select box and want to use custom icon. From the previous answers on SO, I have found out that it is not possible (to make it work with major browsers). Only possibility is to wrap the select inside a div, and set its width more than the div width and setting overflow: hidden.
I am trying following, but it does not work. What I'm doing wrong?
.selectParent {
width: 80px;
overflow: hidden;
}
.selectParent select {
width: 100px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 2px 30px 2px 2px;
border: none;
background: transparent url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat right center;
}
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
JSFiddle:
http://jsfiddle.net/gcPmC/
Please follow the way like below:
.selectParent {
width:120px;
overflow:hidden;
}
.selectParent select {
display: block;
width: 100%;
padding: 2px 25px 2px 2px;
border: none;
background: url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") right center no-repeat;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
.selectParent.left select {
direction: rtl;
padding: 2px 2px 2px 25px;
background-position: left center;
}
/* for IE and Edge */
select::-ms-expand {
display: none;
}
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
<br />
<div class="selectParent left">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
Try to replace the
padding: 2px 30px 2px 2px;
with
padding: 2px 2px 2px 2px;
It should work.