Home  >  Article  >  Web Front-end  >  Example code sharing of css pseudo-class combination usage

Example code sharing of css pseudo-class combination usage

黄舟
黄舟Original
2017-04-24 09:35:271245browse

Using pseudo-class combination, you can use css instead of js to achieve the purpose, less js

.textarea:empty:before {
    display: block;
    content: '请输入';
    color: #ababab;
    font-size: 15px;
    text-align: left;
}<br>//表示:当textarea元素为空时即没有输入时,有“请输入”这句提示语显示
  
.textarea:focus:before {
    display: none;
}<br>//当textarea元素聚焦时,刚刚用before伪类加的“请输入”就会隐藏<br><br>.textarea:empty:after {
content: &#39;请认真填写。&#39;;
   color: #ababab;
   font-size: 11px;
   text-align: left;
}
.textarea:focus:focus {
    display: none;
}
first-child:after
.order:empty+.a {
    display: block;
}<br>//order元素为空时,它下面的那个元素a显示

The above is the detailed content of Example code sharing of css pseudo-class combination usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn