IE Select Box option element height not working - html

select item option lists are not showing properly in IE.
need to add padding and height for option element. Does any one knows how to fix this?
CSS
.reser_item_long select {
width: 106%;
width: 106.5%\9;
height: 33px;
*height: 33px;
float: left;
text-align: left;
border: none;
outline: none;
background: none;
cursor: pointer;
overflow: hidden;
text-transform: uppercase;
font-size: 10px;
color: #889099;
color: #889099\9 !important;
padding: 9px 0 0 7px;
padding: 0 0 0 7px\9 ;
padding: 0 0 0 7px\0/;
display:block;
(-bracket-:hack;
padding: 2px 0 0 7px ;
);
}
HTML
<div class="reser_item_long">
<div class="select-wrapper">
<select id="cmb-country" name="cmb-country">
<option value="-1">Please Select a Country</option>
<option value="0">Afghanistan</option>
<option value="0">Ă…land Islands</option>
<option value="0">Albania</option>
<option value="0">Algeria</option>
</select>
</div>
</div>

There is no work-around for this aside from ditching the select element

You should differently edit this question and add you browser version. But let me give you a solution after all.
The problem is that the Select, options, file inputs are rendered by the OS/Browser and not by the HTML itself and therefor give's problem in styling it.
You can via javascript simulate and style your own dropdown to make sure it looks the same way in every browser and OS. Basically it generates something that look and feels like a dropdown list but is just an interface for the hidden select in your code.
You could use something like http://formalize.me/ to style all forms elements on your page.

Related

How do I put static text in a select element in html?

I currently have a select element as follows:
<select class="select" id="startYear" onChange={(event) => setStartYear(event.target.value)}>
Then I have a bunch of options elements as well. Each looking as follows:
<option value=2017 selected={2017 == startYear}>2017</option>
<option value=2018 selected={2018 == startYear}>2018</option>
//lots of different years continuing on
I'm hoping to make it so that there's a static text that says "Start:" and then the dropdown is just all of the years (without the text). See the image below as an example. Anyone know where I can add the "Start:" text?
You would usually use a label for this kind of thing, where the label is to the left and the select box to the right.
div {
border: 1px solid black;
width: 100px;
border-radius: 15px;
padding: 5px 0 5px 10px
}
select {
border: none
}
<div>
<label for="start">Start: </label>
<select id="start">
<option>2017</option>
</select>
</div>
There is still an arrow there which your example image doesn't show, however, I would argue that you want to have the arrow there to denote that it's a select box/drop down. Without it, there's no indication and it's not friendly UX.
I was able to achieve this effect by surrounding the whole thing in a div, and adding the text and select there. With some css, it looks like a normal select prompt. You may have to fiddle with some of the variables to make it to your liking.
.select{
display: inline-block;
border: 2px solid black;
border-radius: 5px;
padding: 5px;
}
.select select {
display: inline-block;
border: none;
background-color: transparent;
}
.select select:focus-visible{
background-color: transparent;
border: none;
outline: none;
}
.select p {
display: inline-block;
text-align: center;
margin: 0;
}
<div class="select">
<p>Start:</p>
<select>
<option>15432542</option>
<option>54326</option>
<option>654262</option>
</select>
</div>

How do you center text in a select drop down menu, style the drop down and add a down arrow?

This is killing me. I have 2 select menus that I need to center the text. I've tried varieties of text-align: center, margin: 0 auto, etc. I can't use padding because all of the element's names are different sizes. Any thoughts?
Here is the rails piece of code that makes a select drop down.
<%= collection_select(:id, :name, #restaurants, :id, :name, prompt: "select a restaurant") %>
Here is what the code looks like when produced in html.
<select id="id_name" name="id[name]"><option value="">select a restaurant</option>
<option value="5">Jamba</option>
<option value="4">Smokey Joes</option>
<option value="3">Arbys</option>
<option value="1">McDonalds</option>
<option value="2">Burger King</option></select>
Current styling. Every time I tried to style option, it did nothing.
.filters{
height: auto;
margin: 0 auto;
overflow: hidden;
padding-bottom: 10px;
width: 280px;
select {
background-color: rgba(255,255,255,0.71);
background:-webkit-linear-gradient(bottom,rgba(255,255,255,0.71) 71%, rgba(255,255,255,0.71) 71%);
background:-o-linear-gradient(bottom,rgba(255,255,255,0.71) 71%, rgba(255,255,255,0.71) 71%);
background:-moz-linear-gradient(bottom,rgba(255,255,255,0.71) 71%, rgba(255,255,255,0.71) 71%);
border: 1px solid #fff;
border-radius: 0;
color: #553705;
font-size: 18px;
height: 48px;
margin-top: -4px;
padding: 10px 5px;
width: 100%;
-webkit-appearance: none;
&:hover{
cursor: pointer;
}
}
}
I also need to add a little drop down arrow in the select, but not sure what element to put the :after on. Here is ideally how I would like the site to look:
Any other thoughts on styling the options would be appreciated too. Right now when I open it, it opens slightly to the side. Here is a picture
Based on this response, https://stackoverflow.com/a/10813603/1949363, it seems not possible to achieve what you need in vanilla CSS. The mentioned post recommends using a jQuery plugin as an option, which doesn't sound all that fun.
Its posible with:
select { width: 400px; text-align:center; } select > option { text-center !important; }

Customize <select> and <option> elements

I have a select element:
<div class="select">
<select id="relationship" name="relationship">
<option value="">one</option>
<option value="">two</option>
<option value="">three</option>
</select>
</div>
with this CSS:
.select {
font-family: 'irregularisregular',Arial,sans-serif;
font-size: 2.5em;
height: 1.7em;
margin: 0.15em 0.5em;
padding: 0 1em;
width: 40%;
}
.select select {
-moz-appearance: window;
background: none repeat scroll 0 0 transparent;
border: 0 none;
overflow: hidden;
width: 100%;
}
When I click on the select, the options appear, but the block doesn't have the same size as the select block. I don't know what to change so the two blocks <select> and <option> have the same width.
Apart from the other CSS that you have, to ensure same width for the select and its options you should add something in the lines of:
select, select option {
width: 200px; /* change as needed */
}
The two block mentioned does have the same width. Its just hat u have padding in your parent div(.select) and no border on 'select' which is making it "look" bigger that's it.

html select box down arrow looks like mouse

On IE8,9 and 10 a select element looks like the attached picture. The drop down arrow is replaced with something that looks more or less like a mouse.
On Firefox and Chrome it looks like a standard drop down with a down arrow.
I can't find anywhere that I've done anything with CSS to alter selects.
Any suggestions?
<td>
<select id='allocated' name='alloc' onchange='allocChange()'>
<option value='??' selected='selected'>??</option>
<option value='1A' >1A</option>
<option value='1B' >1B</option>
<option value='1C' >1C</option>
<option value='2A' >2A</option>
<option value='2B' >2B</option>
<option value='3A' >3A</option>
</select>
</td>
CSS not a factor - same thing happens even when stylesheet not loaded
It may be by default.. But you can change the arrow using css
.styleSelect select {
background: transparent;
width: 168px;
padding: 5px;
font-size: 16px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;
color: #000;
}
.styleSelect {
width: 140px;
height: 34px;
overflow: hidden;
background: url("images/downArrow.png") no-repeat right #fff;
border: 2px solid #000;
}

Select box text stuck to top of box in FF

I have a select field and no matter what I do I can't get the text to stop sticking to the top of the box.
Here is an example of how it looks:
If I use padding-top then it pushes down the arrow button as well, which I don't want. I have also tried line-height with no effect.
Here is the relevant CSS:
#header .nav .misc .search .search_holder .cats select {
width: 111px;
height: 29px;
border-top: 1px solid #97ad00;
border-bottom: 1px solid #97ad00;
border-left: none;
border-right: none;
padding-left: 8px;
font-family: Roboto, Arial;
font-size: 14px;
background: url('../images/search-cats-bg.png') 0 0 repeat-x;
color: #b2b2b2;
}
#header .nav .misc .search .search_holder .cats select option {
padding-top: 5px;
}
#header .nav .misc .search .search_holder .cats select option.last {
padding-bottom: 5px;
}
Edit: Added HTML.
HTML:
<div class="cats">
<select id="search_cats" class="search_cats" name="cat">
<option value="all">All Categories</option>
<option value="sports">Sports Cards</option>
<option value="gaming">Gaming Cards</option>
<option value="non-sport">Non-Sport Cards</option>
<option value="supplies" class="last">Supplies & Storage</option>
</select>
</div>
Why is it doing this and how can I fix it?
Edit: Seems it can't really be fixed, found this question:
I want to vertical-align text in select box
If you look at the answer from "Shelly Skeens" then you will find that FF decided to set the built-in line-height to normal !important and hence it can't be overridden.
try add that
.cats * { line-height: 16px; }
works fine on google chrome ,and google developer tools