css偽類組合用法的範例程式碼分享

來源:互聯網
上載者:User
利用偽類組合,可以用css代替js以達到目的,少些一下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: '請認真填寫。';   color: #ababab;   font-size: 11px;   text-align: left;}.textarea:focus:focus {    display: none;}first-child:after.order:empty+.a {    display: block;}<br>//order元素為空白時,它下面的那個元素a顯示
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.