Input vacío con CSS

5/Jul/2017 20

Reto: diseñador envió una interfaz donde un color diferente no sólo al placeholder, sino al background-color del mismo input como se ve a continuación:

Screen Shot 2017-07-05 at 09.42.26

Me dije:

OK, puedo cambiarle el color al texto del placeholder pero no conozco una propiedad CSS que me diga si el input está vacío para darle el color de fondo al input. Y no quiero meter JS sólo para eso. Investigaré.


Esta propiedad es aún un Working Draft pero actualmente tiene soporte para Firefox, Chrome, Safari, Opera y los browsers móviles más populares. Si, IE no está soportado aún pero qué diablos.

A continuación, el CSS con el cual logré lo que el diseño se proponía:

input {
  display: block;
  width: 100%;
  padding: .6em .8em;
  margin-bottom: .5em;
  font-size: 1.1em;
  color: #1C2E36;
  border: 1px solid #D6E1E4;

input:focus {
  border-color: #00BA68;
  background-color: #FAFBFC;
  outline: 0;

input:placeholder-shown {
  background-color: #FAFBFC;

input::-webkit-input-placeholder {
  color: #A4B3B7;

JS Bin on



  1. dasnaefr [#]

    Amigo, tiempo sin visitar tu sitio, pero veo que sigues siendo Grande.
    Gracias por estos detalles que dia a dia nos vuelven mas creativos, curiosos y practicos.
    Saludos desde CA

  2. hulu [#]

    Great website. Plenty of helpful info here. I am sending it to several buddies ans additionally sharing in delicious. And of course, thanks for your effort! Carlyn Garrett Jez

  3. altyazili [#]

    I know this site provides quality dependent articles and additional information, is there any other website which offers these kinds of information in quality? Kathi Alvy Dielu

  4. torrent [#]

    Great post! We will be linking to this particularly great article on our site. Keep up the good writing. Marje Brew Ursola

  5. torrent [#]

    What a nice article. It keeps me reading more and more! Daisey Vernon Cinderella

  6. yabanci [#]

    The following time I review a blog, I really hope that it does not dissatisfy me as high as this set. I mean, I recognize it was my choice to review, yet I really assumed youd have something interesting to state. All I hear is a lot of yawping concerning something that you might deal with if you werent as well hectic searching for attention. Cloris Bran Nellie

  7. indirmeden [#]

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam semper leo eget sapien ultrices vitae facilisis massa dictum. Fusce eu purus a urna accumsan luctus. Nullam sit amet nisi non ante ultrices egestas. Proin erat nulla, congue adipiscing accumsan id, sollicitudin eget dolor. Vestibulum ipsum urna, consequat vel cursus ut, scelerisque vel nisl. Suspendisse molestie facilisis dui, et rutrum enim fermentum id. Curabitur tincidunt tellus sed risus vulputate fringilla. Mauris luctus posuere odio, quis viverra purus consequat ac. Aliquam luctus posuere ultricies. Morbi sagittis elementum ligula, eget luctus diam facilisis sit amet. Maecenas fringilla cursus tortor, nec dictum purus volutpat et. Lynda Marv Ameline

  8. altyazili [#]

    Good post. I learn something totally new and challenging on websites I stumbleupon on a daily basis. It will always be useful to read through articles from other authors and use something from other sites. Atalanta Ives Kendrick

  9. bedava [#]

    This is a really good story, complete with that moment of suspense and a near mishap. Boar hide sounds like the closest thing to Kevlar. Wendye Goran Dara

  10. 720p [#]

    Really nice pattern and superb written content, very little else we want :D. Morena Fremont Sperling

  11. online [#]

    I have recently started a site, the information you provide on this site has helped me tremendously. Thank you for all of your time & work. Cara Rey Susan

  12. hindi movie [#]

    Some truly excellent posts on this website , appreciate it for contribution. Lisabeth Dannel McMullan

  13. turkce [#]

    I get pleasure from, result in I found just what I used to be taking a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye Chrystal Bard Kubetz

  14. erotik [#]

    This is the type of movie that the less you know, the more enjoyable it will be. Ninetta Cal Torrey

  15. liquid cialis [#]

    cialis canada

  16. Ifyeij [#]

    generic tadalafil online – tadalafil 5mg generic tadalafil 20mg

  17. Bewion [#]

    canadian pharmacy tadalafil – canadian online pharmacy tadalafil tadalafil coupon

  18. brimonidine [#]

    combigan generic prices generic combigan

  19. combigan [#]

    combigan side effects brimonidine use

  20. Megalis [#]

    tadalafil pills tadalafil tablets 40mg

Deja tu Comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *