In CSS it is possible to style placeholder
text within an input using a combination of vendor-specific pseudo-classes and pseudo-elements (to get the best cross-browser coverage).
These all share the same basic properties (ie: text styling and color declarations).
However whilst I inevitably want to apply the same styles irrespective of browser vendor, it doesn't appear to be possible to combine these together into a comma-separated selector (as you would with any other piece of CSS where you want two selectors to share the same styles).
As an example, I tend to target placeholder styling using the four following selectors:
input:-moz-placeholder
input::-moz-placeholder
input:-ms-input-placeholder
input::-webkit-input-placeholder
(although :-moz-placeholder
is being deprecated in favor of ::-moz-placeholder
this only occurred with the release of FireFox 19 so at present both are needed for better browser-support).
What's frustrating is that declaring and giving each (the same) style leads to a lot of repetition within the CSS.
So, to make sure that placeholder text is right-aligned and italic, I would end up with:
input:-moz-placeholder{
font-style: italic;
text-align: right;
}
input::-moz-placeholder{
font-style: italic;
text-align: right;
}
input:-ms-input-placeholder{
font-style: italic;
text-align: right;
}
input::-webkit-input-placeholder{
font-style: italic;
text-align: right;
}
What I really want to do is to combine them as one single comma-seperated rule set like this:
input:-moz-placeholder,
input::-moz-placeholder,
input:-ms-input-placeholder,
input::-webkit-input-placeholder{
font-style: italic;
text-align: right;
}
However, despite trying this on a fair few occasions, this never seems to work. It makes me concerned that there's some fundamental part of CSS that I'm not understanding.
Can anybody shed any light on why this happens?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…