Can i somehow remove this dashed border in drop down list. Every time i click on drop down list i get this dashed border. Example is in image.
edit:
css:
option {
height: 20px;
padding: 7px 0 5px 3px;
outline: none;
border: none;
}
html:
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
<option value="">Razvrsti restavracije po</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
</select>
I think the border is used by some people who prefer to navigate using their keyboard. So it might not be a good idea to remove it.
I don't think it is possible with CSS. What is known is that dashed border has the same color as text, so if you set the text-color same as your background it will "disappear" but your text will too:
Maybe you can play with some javascript:
onmouseover="this.style.color='#DFF1FA'" onmouseout="this.style.color='#000000'"
Or add this at your onchange att: this.blur()
<select onchange="window.open(this.options[this.selectedIndex].value,'_top'); this.blur()">
<option value="" style="color:black">Razvrsti restavracije po</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
<option value="#">Odrto test</option>
</select>
With it the dashed outline will disappear after choosing an option.
You can do even more...
JavaScript rulez!
You can disable such borders using the css outline property:
outline: none;
Related
Hi there wonderful people. I have a question, it may be only related to firefox but, how do I change the color of the selected <option> when the focus is in and out of the <select>? I don't mean on :hover that works fine I'm talking when you click on a <option> and after that when you click out of the <select> object.
The intention is to change the background-color/color of the selected <option> when the <select> is in focus or not in focus. In Firefox it shows in windows system blue/white with dotted outline and in Chrome is showing in a lightb blue/white on focus and white/grey on out of focus... I don't want that.
CSS
.select_style{
background-color: #555;
}
.select_style option{
background-color: #ccc;
}
.select_style option:hover{
background-color: #0f0;
}
HTML
<select class="select_style" size='3' multiple='multiple'>
<option value="">Please choose</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
This made the trick, remember the code is using a a "selectbox" <select> with the attribute multiple it does't act as the normal "droplist" <select>.
CSS
option:checked{
background: #00ff00 !important;
box-shadow: 0 0 10px 100px #00ff00 inset;
}
I am using select 2 https://select2.org/ and I am wondering how do I change the colour of selected option with the value="4". So when Mark as destroyed is selected it shows in a different colour. I tried setting class and inline css directly but both did not work.
Not working: <option value="4" class="tx-orange">Mark as destroyed</option>
Not working: <option value="4" style="color:orange;">Mark as destroyed</option>
This is how the select block looks like
<select id="scanActionOptions" class="form-control select2">
<option value="0">Verify</option>
<option value="1">Mark as active</option>
<option value="2">Mark as dispense</option>
<option value="3">Mark as stolen</option>
<option value="4">Mark as destroyed</option>
<option value="5">Mark as sample</option>
<option value="6">Mark as free sample</option>
<option value="7">Mark as locked</option>
<option value="8">Mark as exported</option>
<option value="9">Mark as checkout</option>
<option value="10">Mark as expired</option>
<option value="11">Mark as recalled</option>
<option value="12">Mark as withdrawn</option>
</select>
$(document).ready(function() {
$('.select2').select2();
});
/*selected css*/
.select2-container--default .select2-results__option--selected {
color: orange;
background:rgb(221 221 221 / 32%) !important;
}
/*hover css*/
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
background-color: orange !important;
color: white;
}
/*particular option color*/
.select2-container--default .select2-results>.select2-results__options li:nth-child(2) {
color: #fff;
background: red !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/select2#4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2#4.1.0-beta.1/dist/js/select2.min.js"></script>
<select id="scanActionOptions" class="form-control select2">
<option value="0">Verify</option>
<option value="1">Mark as active</option>
<option value="2">Mark as dispense</option>
<option value="3">Mark as stolen</option>
<option value="4">Mark as destroyed</option>
<option value="5">Mark as sample</option>
<option value="6">Mark as free sample</option>
<option value="7">Mark as locked</option>
<option value="8">Mark as exported</option>
<option value="9">Mark as checkout</option>
<option value="10">Mark as expired</option>
<option value="11">Mark as recalled</option>
<option value="12">Mark as withdrawn</option>
</select>
If you need to change selected colour apply css on ".select2-container--default .select2-results__option--selected" and change hover css then apply on ".select2-container--default .select2-results__option--highlighted.select2-results__option--selectable".
If you need colour particular option like 2nd option then you can use ".select2-container--default .select2-results>.select2-results__options li:nth-child(2)" .
Select2 CSS seems getting the style from this rule-set
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
background-color: #5897fb;
color: white;
}
You might use li:nth-child(x) applied to the rule-set shown before. CSS aplied to the original select won't be visible.
Tried a lot to change the background color of select option on hover but unable to do so please help me to find the solution.
select.rangs option:hover {
box-shadow: 0 0 10px 100px #ffea00 inset;}
option.rang:hover {
background: #ffea00 !important;}
<select id="order" name="order" title="order" class="form-control form-login__input-field label-error rangs">
<option class="rang" value="">Sort By</option>
<option class="rang" value="popular">Most popular</option>
<option class="rang" value="register_desc">Oldest First</option>
<option class="rang" value="register_asc">Newest First</option>
I want the background color to be changed on hover in chrome
You cannot change the background of the <option>, you can't set script or style inside option element. This is used to show only text inside option element no matter what text , style or scripts
The main property of option element is value that's why there is no need to add CSS on text inside <option>
You could only apply CSS on <select>:
select {
background: #ffea00;
}
Following code will help you. Run Code Snippet.
.rang:hover { background: #ffea00 !important;}
<select id="order" name="order" title="order" class="form-control form-login__input-field label-error rangs">
<option class="rang" value="">Sort By</option>
<option class="rang" value="popular">Most popular</option>
<option class="rang" value="register_desc">Oldest First</option>
<option class="rang" value="register_asc">Newest First</option>
</select>
I have a select list which has the attribute 'required' with the first item set as disabled and selected:
<select tabindex='4' id='storeys' name='storeys' required >
<option selected disabled>Select an option</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>
My css is:
select{
border: 1px solid rgb(171, 171, 171);
height: 24px;
font-size: 16px;
height:24px;
width:250px;
color:grey;
}
option{color: #000;}
option:first-child{color: #ccc;}
select:required{border-right:3px solid red;}
select:valid{border-right: 3px solid green;}
Question is how do I make the select list border red when the selected option has no value(ie the disabled option) and green when a value has been selected
I have added fiddle here http://jsfiddle.net/czs1w6br/ which also has a text input demonstrating the effect
Currently, the value property of your first option would be "Select an option", which is a perfectly valid value.
Give the first option an empty value attribute:
<select tabindex='4' id='storeys' name='storeys' required >
<option value='' selected disabled>Select an option</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>
JSFiddle
html,
<select id="start_time" name="start_time" class="hasTimeEntry">
<option value="00:00">00:00</option>
<option value="00:30">00:30</option>
<option value="01:00">01:00</option>
<option value="01:30">01:30</option>
<option value="02:00">02:00</option>
<option value="02:30">02:30</option>
<option value="03:00">03:00</option>
<option value="03:30">03:30</option>
<option value="04:00">04:00</option>
<option value="04:30">04:30</option>
<option value="05:00">05:00</option>
<option value="05:30">05:30</option>
<option value="06:00">06:00</option>
<option value="06:30">06:30</option>
<option value="07:00">07:00</option>
<option value="07:30">07:30</option>
<option value="08:00">08:00</option>
<option value="08:30">08:30</option>
<option value="09:00">09:00</option>
<option value="09:30">09:30</option>
<option value="10:00">10:00</option>
<option value="10:30">10:30</option>
<option value="11:00">11:00</option>
<option value="11:30">11:30</option>
<option value="12:00">12:00</option>
<option value="12:30">12:30</option>
<option value="13:00">13:00</option>
<option value="13:30">13:30</option>
<option value="14:00">14:00</option>
<option value="14:30">14:30</option>
<option value="15:00">15:00</option>
<option value="15:30">15:30</option>
<option value="16:00">16:00</option>
<option value="16:30">16:30</option>
<option value="17:00">17:00</option>
<option value="17:30">17:30</option>
<option value="18:00">18:00</option>
<option value="18:30">18:30</option>
<option value="19:00">19:00</option>
<option value="19:30">19:30</option>
<option value="20:00">20:00</option>
<option value="20:30">20:30</option>
<option value="21:00">21:00</option>
<option value="21:30">21:30</option>
<option value="22:00">22:00</option>
<option value="22:30">22:30</option>
<option value="23:00">23:00</option>
<option value="23:30">23:30</option></select>
css,
#start_time {
background: url(/images/startclock_icon_small.gif) no-repeat scroll 1px 1px;
text-indent: 20px;
border-width: 1px 1px 1px 1px;
width: 142px;
}
if i run this it shows like this,
as you can see in the pic, if i put the
background:url attributes
it shows a different design that i dont want.
i want the same design like the right textfield.
if i comment the background : url it shows fine
however, i need this img icon as a background img :(
any good idea????
========================================
fiddle demo
DEMO
=================================
still design that i don't want
Try this :-
#start_time {
background: url(/images/startclock_icon_small.gif) no-repeat scroll 1px 1px !important;
}
Your hasTimeEntry class is overriding your background property.
Put this inline style on element which isn't working.
style="border-color: #ccc !important;"