css 单选按钮的效果图

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>form</title>
  <link href="css/common.css" rel="stylesheet" type="text/css">
  <style>
    body {
      font:  12px/22px "微软雅黑";
    }
    a {
      color: #000000;
      text-decoration: none;
    }
    .dispatch {
      width: 400px; 
      height: 32px; 
      border: 1px solid #dfdfdf;
      margin: 30px auto;
    }
    .dispatch dl {
      height: 32px;
      line-height: 32px;
      padding-left: 15px;

    }
    .dispatch dt {
      float: left;
    }
    .dispatch dd {
      float: left;
      margin: 0 10px 0 8px;
    }
    .dispatch dd a {
      display: block;
      position: relative;
      padding-left: 23px;
    }
    .dispatch dd a:hover {
      color: #CC0000;
      text-decoration: underline;
    }
    .dispatch dd b {
      display: block;
      width: 20px;
      height: 20px;
      background: url("img/radiobutton.gif") no-repeat -14px -18px;
      position: absolute;
      top: 6px;
      left: 0;
    }
    .dispatch dd a:hover b {
      background: url("img/radiobutton.gif") no-repeat -14px -118px;
    }
    .dispatch .selected b{
      background: url("img/radiobutton.gif") no-repeat -14px -218px;
    }
  </style>
  <script>
    function show(index) {
      var dd = document.getElementById("dispatch").getElementsByTagName('dd');
      for (var i =0; i<dd.length; i++) {
        if (i==index) {
          dd[i].className = "selected";
        } else {
          dd[i].className = "";
        }
      }
    }
  </script>
</head>
<body>
  <div class="dispatch">
    <!-- <form action="#" method="post" name="dispatchForm">
      <label>配送类型</label>
      <input type="radio" name="type" checked/><label>全部</label>
      <input type="radio" name="type" /><label>京东配送</label>
      <input type="radio" name="type" /><label>第三方配送</label>
    </form> -->
    <dl id="dispatch">
      <dt>配送类型:</dt>
      <dd class="selected"><a href="#" onclick="show(0)"><b></b>全部</a></dd>
      <dd><a href="#" onclick="show(1)"><b></b>京东配送</a></dd>
      <dd><a href="#" onclick="show(2)"><b></b>第三方配送</a></dd>
    </dl>
  </div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值