Last active
July 28, 2018 05:46
-
-
Save adamlaki/bd52d134881a5576dca4ddcf1ab2a8d2 to your computer and use it in GitHub Desktop.
Set HTML5 Input's Placeholder Style with CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action=""> | |
<input type="text" name="fname" placeholder="Your First Name"> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input[type="text"]::-webkit-input-placeholder { | |
color: red; | |
} | |
input[type="text"]:-moz-placeholder { | |
color: #0db1ff; /* Firefox 4-18 */ | |
} | |
input[type="text"]::-moz-placeholder { | |
color: #0db1ff; /* Firefox 19+ */ | |
} | |
input[type="text"]:-ms-input-placeholder { | |
color: #0db1ff; /* IE10+ */ | |
} | |
input[type="text"]::-ms-input-placeholder { | |
color: #0db1ff; /* Edge */ | |
} | |
input[type="text"]::placeholder { | |
color: #0db1ff; /* Modern browsers */ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin placeholder($color) { | |
&::-webkit-input-placeholder { | |
color: $color; | |
} | |
&:-moz-placeholder { | |
color: $color; | |
} | |
&::-moz-placeholder { | |
color: $color; | |
} | |
&:-ms-input-placeholder { | |
color: $color; | |
} | |
&::-ms-input-placeholder { | |
color: $color; | |
} | |
&::placeholder { | |
color: $color; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment