Jak zmienić kolor zastępczy na ostrości?
Jak zmienić kolor elementu zastępczego podczas ustawiania ostrości pola wejściowego? Używam tego css, aby ustawić domyślny kolor, ale jak zmienić go na ostrości?
::-webkit-input-placeholder { color: #999; }
/* Firefox < 19 */
:-moz-placeholder { color: #999; }
/* Firefox > 19 */
::-moz-placeholder { color: #999; }
/* Internet Explorer 10 */
:-ms-input-placeholder { color: #999; }
9 answers
Spróbuj tego, to powinno zadziałać:
input::-webkit-input-placeholder {
color: #999;
}
input:focus::-webkit-input-placeholder {
color: red;
}
/* Firefox < 19 */
input:-moz-placeholder {
color: #999;
}
input:focus:-moz-placeholder {
color: red;
}
/* Firefox > 19 */
input::-moz-placeholder {
color: #999;
}
input:focus::-moz-placeholder {
color: red;
}
/* Internet Explorer 10 */
input:-ms-input-placeholder {
color: #999;
}
input:focus:-ms-input-placeholder {
color: red;
}
Oto przykład: http://jsfiddle.net/XDutj/27/
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-05-10 04:06:23
Oprócz odpowiedzi Pranav udoskonaliłem Kod ze zgodnością textarea:
::-webkit-input-placeholder { color: #999; }
:-moz-placeholder { color: #999; }
:focus::-webkit-input-placeholder { color: #ccc; }
:focus:-moz-placeholder { color: #ccc; }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-01 20:06:55
Zadziałało dla mnie:
input:focus::-webkit-input-placeholder
{
color: red;
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-01-02 17:17:56
Spróbuj tego:
HTML
<input type='text' placeholder='Enter text' />
CSS
input[placeholder]:focus { color: red; }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-01 18:37:52
Znalazłem to rozwiązanie z JQuery:
$('input[type="text"]').each(function(){
$(this).focus(function(){
$(this).addClass('input-focus');
});
$(this).blur(function(){
$(this).removeClass('input-focus');
});
});
Z tym css:
.input-focus::-webkit-input-placeholder { color: #f00; }
.input-focus:-moz-placeholder { color: #f00; }
.input-focus:-ms-input-placeholder { color: #f00; }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-01 18:56:44
Użyj Gwiazdy *
, aby wybrać Wszystko
*::-webkit-input-placeholder { color: #999; }
*:-moz-placeholder { color: #999; }
*::-moz-placeholder { color: #999; }
*:-ms-input-placeholder { color: #999; }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-02 00:56:49
To działa dla mnie:
input:focus::placeholder {
color: blue;
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-09-18 17:32:14
Z Firefoksa 19: Pseudo-Klasa:-moz-placeholder, która pasuje do elementów formularza z atrybutem placeholder została usunięta, a zamiast tego dodano pseudo-element::-moz-placeholder.
input:focus::-moz-placeholder { color: transparent; }
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-02-23 21:23:12
Można utworzyć animowany Element Zastępczy projektu materiału, który kurczy się na górze, gdy pole wejściowe jest skupione.
<div class="field">
<input type="text" name="user" required><br>
<label>Enter Username</label>
</div>
Zasadniczo pole etykiety będzie działać jak symbol zastępczy. Możemy to zrobić tylko za pomocą css. Wyjaśnione tutaj http://www.voidtricks.com/create-material-design-animated-placeholder/
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-26 12:17:53