css改變input框樣式


 目前博主只知道兩種方法,如果有同學有別的方法歡迎進行討論

  

一:利用偽類元素改變radio樣式 (此方法無需添加額外的標簽,更便捷)

  .div input[type=radio]::after {
    position: absolute;
    width: 25px;
    height: 25px;
    background: url(../img/inputBG.jpg) no-repeat;
    background-size: 100% 100%;
  }

二:利用label指向input,通過改變label樣式來達到效果   

  <html>  

    <input type="checkbox" checked="checked" id="aa"/><label for="aa"></label>

  </html>

  <style>

    input[type=checkbox]{

       visibility: hidden;

    }

    label{

      width:20px;

      height:20px;

      border:1px solid #707070;

    }

    input[type=checkbox]:checked + label{

      background: url(../img/duigou.jpg)no-repeat;
      background-size: 100% 100%;

    }

  </style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM