CSS3 | Placeholder - Animation
A placeholder animation styled with CSS3. If you click in the textcontent the placeholder fades way in transparency.
HTML
<input type="text" placeholder="Click here...">
<<style>
input[placeholder],
input:-moz-placeholder, /* Mozilla Firefox 4 to 18 */
input::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #8D8D8D;
}
input::-webkit-input-placeholder {
color: #8D8D8D;
}
input:-ms-input-placeholder {
color: #8D8D8D;
}
input[placeholder]:focus,
input:focus:-moz-placeholder, /* Mozilla Firefox 4 to 18 */
input:focus::-moz-placeholder { /* Mozilla Firefox 19+ */
-moz-animation-duration: 0.4s;
-moz-animation-name: slidein;
-moz-animation-timing-function: ease-out;
-moz-animation-fill-mode: forwards;
-moz-animation-delay: 0.1s;
}
input:focus::-webkit-input-placeholder {
-webkit-animation-duration: 0.4s;
-webkit-animation-name: slidein;
-webkit-animation-timing-function: ease-out;
-webkit-animation-fill-mode: forwards;
-webkit-animation-delay: 0.1s;
}
input:focus:-ms-input-placeholder {
opacity: 0;
}
input {
color: black;
padding-left: 0px;
padding-right: 10px;
}
@-webkit-keyframes slidein {
from {
opacity: 1;
padding-left: 0px;
}
to {
opacity: 0;
padding-left: 10px;
}
}
@-moz-keyframes slidein {
from {
opacity: 1;
padding-left: 0px;
padding-right: 10px;
}
to {
opacity: 0;
padding-left: 10px;
padding-right: 0px;
}
}
</style>
CSS
input[placeholder],
input:-moz-placeholder, /* Mozilla Firefox 4 to 18 */
input::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #8D8D8D;
}
input::-webkit-input-placeholder {
color: #8D8D8D;
}
input:-ms-input-placeholder {
color: #8D8D8D;
}
input[placeholder]:focus,
input:focus:-moz-placeholder, /* Mozilla Firefox 4 to 18 */
input:focus::-moz-placeholder { /* Mozilla Firefox 19+ */
-moz-animation-duration: 0.4s;
-moz-animation-name: slidein;
-moz-animation-timing-function: ease-out;
-moz-animation-fill-mode: forwards;
-moz-animation-delay: 0.1s;
}
input:focus::-webkit-input-placeholder {
-webkit-animation-duration: 0.4s;
-webkit-animation-name: slidein;
-webkit-animation-timing-function: ease-out;
-webkit-animation-fill-mode: forwards;
-webkit-animation-delay: 0.1s;
}
input:focus:-ms-input-placeholder {
opacity: 0;
}
input {
color: black;
padding-left: 0px;
padding-right: 10px;
}
@-webkit-keyframes slidein {
from {
opacity: 1;
padding-left: 0px;
}
to {
opacity: 0;
padding-left: 10px;
}
}
@-moz-keyframes slidein {
from {
opacity: 1;
padding-left: 0px;
padding-right: 10px;
}
to {
opacity: 0;
padding-left: 10px;
padding-right: 0px;
}
}