單選框和復選框的樣式修改


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>html</title>
  </head>
  <style>
    /* 單選框樣式 */
    .radio input {
      display: none;
    }
    .radio label:active {
      color: #000;
    }
    .radio label {
      width: 100%;
      height: 100%;
      display: inline-block;
      position: relative;
      line-height: 50px;
      color: #999;
      padding-left: 50px;
    }
    .radio label:after {
      content: ""; /*必須設置*/
      display: inline-block;
      width: 20px;
      height: 20px;
      border: 1px solid green;
      position: absolute;
      top: 15px;
      left: 15px;
      border-radius: 20px;
    }
    .radio input:checked + label:after {
      background-color: green;
    }

    /* 多選框的樣式 */
    .checkbox input {
      display: none;
    }
    .checkbox label {
      width: 100%;
      height: 50px;
      display: inline-block;
      line-height: 50px;
      position: relative;
      padding-left: 50px;
    }
    .checkbox label:active {
      background: #eeeeee;
    }
    .checkbox label:after {
      content: "";
      width: 20px;
      height: 20px;
      border: 1px solid green;
      display: inline-block;
      position: absolute;
      top: 15px;
      left: 15px;
    }
    .checkbox input:checked + label:before {
      content: "\2713";
      height: 20px;
      position: absolute;
      top: 0;
      left: 20px;
    }
  </style>
  <body>
    <h1>2018 09 16</h1>

    <div class="radio">
      性別: <input type="radio" name="sex" checked id="man" />
      <label for="man">男</label> <input type="radio" name="sex" id="lady" />
      <label for="lady">女</label>
    </div>

    <div class="checkbox">
      愛好: <input type="checkbox" id="read" /> <label for="read">讀書</label>
      <input type="checkbox" id="swiming" /> <label for="swiming">讀書</label>
      <input type="checkbox" id="basketball" />
      <label for="basketball">讀書</label>
    </div>
  </body>
</html>

 


免責聲明!

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



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