Skip to content

Instantly share code, notes, and snippets.

@movii
Last active June 23, 2017 15:38
Show Gist options
  • Save movii/b1212537464978a276547d46997a05c5 to your computer and use it in GitHub Desktop.
Save movii/b1212537464978a276547d46997a05c5 to your computer and use it in GitHub Desktop.
使用 CSS 伪类为 select 元素添加 placeholder: 4. 可能是正确的答案
<style>
select:required:invalid {
color: gray;
}
option[value=""][disabled] {
display: none;
}
option {
color: black;
}
</style>
<select required>
<option value="" disabled selected>Select something...</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment