Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select border color

I don't seem to be able to get rid of the border (outline, box-shadow?) against the select element in Opera browser.

None of the below rules are removing the border:

select {
  /*border: 0;*/
  border: none;
  outline: 0;
  background: transparent;
  border-image: none;
  outline-offset: -2px;
  border-color: transparent;
  outline-color: transparent;
  box-shadow: none;
}
<select class="form-control">
  <option selected="selected" value="0">Most Popular</option>
  <option value="1">A-Z</option>
  <option value="2">Z-A</option>
  <option value="3">Lowest price</option>
  <option value="4">Highest price</option>
</select>

Opera version is 46.0.2597.57 (PGO).

The above code is working perfectly in other browsers tested - Chrome, Firefox, Internet Explorer and Edge.

Any hint would be helpful.

EDIT I am using Windows 10 64-bit, here is a screenshot:

like image 853
Morpheus Avatar asked Jul 24 '17 13:07

Morpheus


People also ask

How do you change the selected border color in HTML?

Two values, like: p {border-color: red transparent} - top and bottom border will be red, left and right border will be transparent. Three values, like: p {border-color: red green blue}- top border will be red, left and right border will be green, bottom border will be blue.

How do you change border color?

On the Border tab, under Color, click the color that you want to apply, and then under Border, click the specific pieces of the cell border to apply the color to. Click OK. Tip: To apply your new cell style, select the cells that you want to change, and then on the Home tab, under Format, click the style.

Can I color border in CSS?

CSS Demo: border-colorEach side can be set individually using border-top-color , border-right-color , border-bottom-color , and border-left-color ; or using the writing mode-aware border-block-start-color , border-block-end-color , border-inline-start-color , and border-inline-end-color .

Can you set specific colors for table borders?

Answer: You can specify a border color using style sheets, but the colors for a table that does not use style sheets will be the same as the text color.


2 Answers

You can get rid of the border with -webkit-appearance: none;, but this removes the caret too, so you might have to add this again manually. I could not manage to find a better answer to this, since opera is really stubborn with this border. (Updated solution with caret below)

select {
  border: 0;
  outline: 0;
  background: transparent;
  border-image: none;
  outline-offset: -2px;
  border-color: transparent;
  outline-color: transparent;
  box-shadow: none;
  -webkit-appearance: none;
}
<select class="form-control" id="1">
  <option selected="selected" value="0">Most Popular</option> 
  <option value="1">A-Z</option>
  <option value="2">Z-A</option>
  <option value="3">Lowest price</option>
  <option value="4">Highest price</option>
</select>

Updated solution: This is more like a workaround, than a solution, but this has a working "fake" caret, and looks like a borderless dropdown, even in Opera.

select {
  border: 0;
  outline: 0;
  background: transparent;
  border-image: none;
  outline-offset: -2px;
  border-color: transparent;
  outline-color: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  width: 100% ;
  position: absolute;
}

.select-wrapper {
  position: relative;
  max-width: 100px;
}

.select-wrapper:after {
  content: "\25BE";
  float: right;
  margin-top: -3px;
}
<div class="select-wrapper" id="label-for-1">
  <select class="form-control" id="1">
    <option selected="selected" value="0">Most Popular</option>
    <option value="1">A-Z</option>
    <option value="2">Z-A</option>
    <option value="3">Lowest price</option>
    <option value="4">Highest price</option>
  </select>
</div>
like image 131
Matthias Seifert Avatar answered Nov 02 '22 12:11

Matthias Seifert


You can use something like border: 1px solid white to overlap Opera's border if you have solid background behind your select.

Or you can apply custom styles for webkit browsers to your select via CSS hacks targeting specific browser, removing standard appearance using -webkit-appearance: none and applying SVG background-image for standard arrow. This way standard appearance for IE and Firefox will be intact.

select {
  border: 0;
  outline: 0;
  background-color: transparent;
}


/* Select only webkit browsers */
@media screen and (-webkit-min-device-pixel-ratio:0) {
  select {
    /* remove arrow */
    -webkit-appearance: none;
    /* add some padding for image */
    padding-right: 15px; 
    /* apply SVG with arrow */
    /* change width value to move arrow to the left */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="15" viewBox="0 0 15 15"><path d="M 8,5.5 11,9.5 14,5.5 z"></path></svg>');
    background-repeat: no-repeat;
    background-position: center right;
  }
}
<select class="form-control">
  <option selected="selected" value="0">Most Popular</option>
  <option value="1">A-Z</option>
  <option value="2">Z-A</option>
  <option value="3">Lowest price</option>
  <option value="4">Highest price</option>
</select>
like image 28
Vadim Ovchinnikov Avatar answered Nov 02 '22 10:11

Vadim Ovchinnikov