Change border color on <select> HTML form

Is it possible to change the border color on a <select/> element in an HTML form?

The border-color style works in Firefox but not IE.

I could find no real answers on Google.

Upvotes: 23

Views: 168675

Answers (7)

Capricorn
Capricorn

Reputation: 271

<style>
.form-error {
        border: 2px solid #e74c3c;
    }
</style>



<div class="form-error">
                                {!! Form::select('color', $colors->prepend('Please Select Color', ''),           ,['class' => 'form-control dropselect form-error'
                                ,'tabindex' => $count++, 'id' => 'color']) !!}
                                </div>

Upvotes: 0

fuentesjr
fuentesjr

Reputation: 52318

I would consinder enclosing that select block within a div block and setting the border property like this:

<div style="border: 2px solid blue;">
  <select style="width: 100%;">
    <option value="Sal">Sal</option>
    <option value="Awesome">Awesome!</option>
  </select>
</div>

You should be able to play with that to accomplish what you need.

Upvotes: 31

user12091799
user12091799

Reputation:

Replacing the border-color with outline-color should work.

Upvotes: 0

scunliffe
scunliffe

Reputation: 63580

You can set the border color in IE however there are some issues.

Argh... I could have sworn you could do this... just tested and realized I wasn't correct. The notes below still apply though.

  1. in IE8 (Beta1 -> RC1) changing the border color or the background color/image causes a de-theming of the control in WindowsXP (the drop arrow and box look like Windows 95)

  2. you still can't style the options within the select control very well because IE doesn't support it. (see bug #291)

Upvotes: 1

pincopallo
pincopallo

Reputation: 683

select{
    filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=-1, OffY=-1,color=#FF0000) progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1,color=#FF0000);
}

Works for me.

Upvotes: 2

Cerebrus
Cerebrus

Reputation: 25775

As Diodeus stated, IE doesn't allow anything but the default border for <select> elements. However, I know of two hacks to achieve a similar effect :

  1. Use a DIV that is placed absolutely at the same position as the dropdown and set it's borders. It will appear that the dropdown has a border.

  2. Use a Javascript solution, for instance, the one provided here.

It may however prove to be too much effort, so you should evaluate if you really require the border.

Upvotes: 6

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

No, the <select> control is a system-level control, not a client-level control in IE. A few versions back it didn't even play nicely-with z-index, putting itself on top of virtually everything.

To do anything fancy you'll have to emulate the functionality using CSS and your own elements.

Upvotes: 4

Related Questions