css改變input框樣式

 目前博主只知道兩種方法,若是有同窗有別的方法歡迎進行討論css

  

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

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

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

  <html>  url

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

  </html>htm

  <style>blog

    input[type=checkbox]{ip

       visibility: hidden;input

    }

    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>

相關文章
相關標籤/搜索