1

I'm currently trying to change the default placeholder of a disabled option from the default black. to #008752.

Code example below:

        <div class="col-sm-3">
          <select class="form-control" size="auto" id="selectpicker1" required>
          <option value="" disabled selected>Please select...</option>
          <option value="opt01">opt1</option>
          <option value="opt02">opt2</option>
          </select>
        </div>

The line of code that needs to be changed:

<option value="" disabled selected>Please select...</option>

Example of the correct colour below, from the two date inputs, with the slectpicker in its default colour.

enter image description here

The following code below is also not working:

 <option value="" style="color:#008752 !important" disabled selected>Please select...</option>

It changes the wrong text line and not the placeholder.

enter image description here

Just tried the webkit example and it just replaced the other placeholders and not the sector

.form-control::-moz-placeholder {
  color: #008752 !important;
  opacity: 1;
}
.form-control:-ms-input-placeholder {
  color: #008752 !important;
}
.form-control::-webkit-input-placeholder {
  color: #008752 !important;
}

enter image description here

Outcome of webkit test

Mattlinux1
  • 777
  • 2
  • 13
  • 25

5 Answers5

2

This should do the trick.

 ::-webkit-input-placeholder { 
        color:  #008752;
    }
    :-moz-placeholder {
       color:  #008752;
       opacity:  1;
    }
    ::-moz-placeholder {
       color:   #008752;
       opacity:  1;
    }
    :-ms-input-placeholder {
       color:   #008752;
    }
JustinasT
  • 561
  • 1
  • 8
  • 27
  • Try to check: http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css - There are huge post about this. I believe it should be helpful. – JustinasT May 25 '16 at 12:34
1

Do you mean changing "Please select..." to this color? If that's what you want then you could try it with these:

Javascript

document.getElementById('selectpicker1').options[0].style.color = '#008752';

HTML (inline css)

 <option value="" style="color:#008752" disabled selected>Please select...</option>

There are more and efficient ways, but these take the cake.

cthefinal
  • 79
  • 1
1
<style>
    .form-control #disabledtext {
          color : #008752 !important;
    }
</style>

use id="disabledtext"

<div class="col-sm-3">
      <select class="form-control" size="auto" id="selectpicker1" required>
      <option id="disabledtext" value="" disabled selected>Please select...</option>
      <option value="opt01">opt1</option>
      <option value="opt02">opt2</option>
      </select>
    </div>
1

This is fragment form bootstrap.css:

.form-control::-moz-placeholder {
  color: #999;
  opacity: 1;
}
.form-control:-ms-input-placeholder {
  color: #999;
}
.form-control::-webkit-input-placeholder {
  color: #999;
}

So try to change values and add !important to them:

.form-control::-moz-placeholder {
  color: #008752 !important;
  opacity: 1;
}
.form-control:-ms-input-placeholder {
  color: #008752 !important;
}
.form-control::-webkit-input-placeholder {
  color: #008752 !important;
}
Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68
0

Fixed it myself by trying:

<select class="form-control" size="auto" style="color: #008752" id="selectpicker1" required>

enter image description here

Mattlinux1
  • 777
  • 2
  • 13
  • 25