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>

相关文章
相关标签/搜索