Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

复选框样式 #32

Open
zlluGitHub opened this issue Aug 3, 2018 · 0 comments
Open

复选框样式 #32

zlluGitHub opened this issue Aug 3, 2018 · 0 comments

Comments

@zlluGitHub
Copy link
Owner

.box {
      position: relative;
      padding-left: 30px;
    }

    .box input[type=checkbox] {
      position: absolute;
      z-index: -1;
      opacity: 0;
    }
    .test::before {
      left: 0;
      content: '';
      display: block;
      position: absolute;
      width: 20px;
      height: 20px;
      border-radius: 4px;
      background-color: #ccc;
      top: 0;
    }

    .test::after {
      top: 0;
      left: 0;
      content: '';
      display: block;
      position: absolute;
      width: 20px;
      height: 20px;
      background-repeat: no-repeat;
      background-position: center center;
      background-size: cover;
    }

    .box input:checked+.test::before {
      background-color: #00b3d4;
    }

    .box input:checked+.test::after {
      background-image: url('./img/勾.png');
    }


<div class="box">
    <input id='test' type="checkbox">
    <label for="test" class="test">测试按钮</label>
  </div>
  <script>
    // 前端 ui 库    bootstrap
    document.querySelector('#test').onchange = function () {
      console.log(this.checked)
    }
  </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant