Input vacío con CSS

5/Jul/2017 737

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. Delta Air lines San Diego booking customer service [#]

    control of pest San Diego service Diego+service+phone+number

  2. ivermectin contraindications [#]

    stromectol antiparasitic tablet

    explore doppler ultrasound trace

  3. [#]

    how to buy ivermectin ivermectin for humans ivermectine kopen

  4. ivermectin paste 1.87% for humans [#]

    ivermectine generic ivermectin stromectol 3mg tablets dosage

  5. ivermectin instructions for scabies [#]

    You have made some decent points there. I looked on the internet for additional information about
    the issue and found most individuals will go along with
    your views on this site.

  6. supreme hoodie [#]

    I would like to express some thanks to you just for rescuing me from this instance. Just after surfing around through the world wide web and obtaining thoughts that were not productive, I was thinking my life was done. Being alive devoid of the approaches to the problems you have sorted out through the short post is a crucial case, and those that could have adversely affected my entire career if I hadn’t encountered your blog. The skills and kindness in playing with the whole thing was helpful. I am not sure what I would have done if I had not encountered such a stuff like this. I can at this moment relish my future. Thanks for your time so much for the impressive and amazing help. I will not hesitate to recommend your blog to anyone who needs tips on this situation.

  7. kd shoes [#]

    I wish to express my admiration for your kindness in support of people that should have guidance on this field. Your real dedication to getting the solution all-around came to be really functional and has surely empowered most people much like me to attain their ambitions. This useful publication means so much to me and a whole lot more to my colleagues. Thanks a lot; from everyone of us.

  8. a bathing ape [#]

    My wife and i got absolutely delighted when Jordan managed to round up his investigation using the ideas he discovered through your weblog. It is now and again perplexing just to choose to be offering techniques which other folks might have been selling. We really take into account we’ve got the blog owner to be grateful to for that. All the explanations you’ve made, the easy blog navigation, the relationships your site make it possible to instill – it’s mostly spectacular, and it is aiding our son and our family imagine that that subject is exciting, and that’s exceedingly serious. Thank you for the whole lot!

  9. jordan shoes [#]

    A lot of thanks for all your valuable efforts on this web site. My mother enjoys working on investigations and it’s really easy to understand why. All of us know all concerning the compelling ways you create reliable tactics by means of the website and even invigorate contribution from people about this point while our favorite simple princess is certainly starting to learn a whole lot. Enjoy the rest of the year. You’re the one performing a remarkable job.

  10. golden goose [#]

    I am also writing to make you understand what a really good encounter my friend’s child went through using your site. She mastered numerous things, including how it is like to possess a great helping character to make other folks really easily fully grasp some very confusing matters. You undoubtedly surpassed her desires. Many thanks for providing these good, trustworthy, edifying and also easy thoughts on that topic to Jane.

  11. kd 13 [#]

    Thanks for every one of your hard work on this website. Kate takes pleasure in conducting internet research and it is easy to understand why. All of us hear all about the dynamic tactic you render simple ideas by means of your blog and in addition cause contribution from some others on that concept plus our favorite daughter is undoubtedly starting to learn a great deal. Take pleasure in the rest of the new year. You’re doing a powerful job.

  12. supreme t shirt [#]

    I have to show my passion for your kind-heartedness giving support to men and women that need guidance on this theme. Your real commitment to passing the solution along appeared to be exceedingly helpful and have truly encouraged others like me to achieve their desired goals. Your new helpful report indicates a great deal a person like me and especially to my mates. Regards; from all of us.

  13. can you get ivermectin over the counter [#]

    ivermectin pinworms treatment humans

    wheel audiologist mark

  14. grossesse et ivermectin 1g [#]

    stromectol for humans

    segment venous leak literary

  15. buy isotretinoine [#] roaccutane side effects