html - Comment faire pour une boîte de 39;select align#39

Mots clés : htmlcsshtml-selectplaceholderhtml

meilleur 5 Réponses html - Comment faire pour une boîte de 39;select align#39

vote vote

94

<select>     <option value="" disabled selected>Select your option</option>     <option value="hurr">Durr</option> </select>
vote vote

87

<style>  select:invalid { color: gray; }  </style>  <form>  <select required>      <option value="" disabled selected hidden>Please Choose...</option>      <option value="0">Open when powered (most valves do this)</option>      <option value="1">Closed when powered, auto-opens when power is cut</option>  </select>  </form>
vote vote

76

select:required:invalid {    color: gray;  }  option[value=""][disabled] {    display: none;  }  option {    color: black;  }
<select required>    <option value="" disabled selected>Select something...</option>    <option value="1">One</option>    <option value="2">Two</option>  </select>
vote vote

65

<select id="choice">     <option value="0" selected="selected">Choose...</option>     <option value="1">Something</option>     <option value="2">Something else</option>     <option value="3">Another choice</option> </select> 
#choice option { color: black; } .empty { color: gray; } 
$("#choice").change(function () {     if($(this).val() == "0") $(this).addClass("empty");     else $(this).removeClass("empty") });  $("#choice").change(); 
vote vote

53

<select>    <option hidden>Sex</option>    <option>Male</option>    <option>Female</option>  </select>

Questions similaires