Поиск по этому блогу

вторник, 25 августа 2015 г.

CSS. Стиль для Placeholder

При помощи CSS возможно стилизовать атрибут placeholder так как нам нужно. Делается это следующим образом.
::-webkit-input-placeholder {
   color: red;
}
 
:-moz-placeholder { /* Firefox 18- */
   color: red;  
}
 
::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
}
 
:-ms-input-placeholder {  
   color: red;  
}


Допустим у нас имеется текстовое поле ввода.

<input type="text" placeholder="Оставьте сообщение здесь">


Создадим для него класс который будет стилизовать placeholder.
title-not-input {
   input[type="text"]::-webkit-input-placeholder {
       color: #D5193B;   }
   input[type="text"]:-moz-placeholder { color: #D5193B; }
   input[type="text"]::-moz-placeholder { color: #D5193B; }
   input[type="text"]:-ms-input-placeholder { color: #D5193B; }
   input[type="text"] { 
      font-family: "Gotham Light";      
      font-size: 26pt;      
      letter-spacing: 1.3pt;   }
}

Изменять можно следующие свойства placeholder
  • font (и сопутствующие свойства)
  • background (и сопутствующие свойства)
  • color
  • word-spacing
  • letter-spacing
  • text-decoration
  • vertical-align
  • text-transform
  • line-height
  • text-indent
  • text-overflow
  • opacity

Источники

  1. https://css-tricks.com/snippets/css/style-placeholder-text/
  2. http://html5.by/blog/placeholder/
  3. http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css
  4. http://htmlbook.ru/css/-webkit-input-placeholder












2 комментария:

  1. Brilliant! I admire how you focused on practical skills as a full-stack engineer to ace the skill sets and sustain in the industry. Recently I started working as a freelancer for a temporary period to work on my skills by practically improving through real-time projects. And I got an amazing opportunity through Eiliana.com. The platform is worth a specialisation for technical projects.

    ОтветитьУдалить