现在要为大家分享的是纯css3实现的radio单选框,效果超级炫。先让我们看看图吧! ----------------------------------------单选框--Start-------------------------------------------------------- 效果如下 css单选 下面就一起看一下如何实现的吧。。。。

html代码

<form action="#">
  <div class="wrapper">
    <div class="box">
      <input type="radio" checked="checked"  id="boy" name="1" /><span></span>
    </div>
    <lable for="boy">男</lable>
  </div>

  <div class="wrapper">
    <div class="box">
      <input type="radio"  id="girl" name="1"  /><span></span>
    </div>
    <label for="girl">女</label>
  </div>
</form>

CSS代码


form {
  border: 1px solid #ccc;
  padding: 20px;
  width: 300px;
  margin: 30px auto;
}
.wrapper {
  margin-bottom: 10px;
}
.box {
  display: inline-block;
  width: 30px;
  height: 30px;
  margin-right: 10px;
  position: relative;
  background: orange;
  vertical-align: middle;
  border-radius: 100%;
}
.box input {
  opacity: 0;
  positon: absolute;
  top:0;
  left:0;
  wdith: 100%;
  height:100%;
}

.box span { 
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 100%;
  position: absolute;
  background: #fff;
  top: 50%;
  left:50%;
  margin: -5px 0  0 -5px;
}

input[type="radio"] + span {
  opacity: 0;
}
input[type="radio"]:checked + span {
  opacity: 1;
}

----------------------------------------单选框--End--------------------------------------------------------