jquery Tab切换,CSS3制作发光字

jquery Tab切换,CSS3制作发光字

代码如下

html 复制代码
<!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>Tab</title>
  <style>
    * {
      margin: 0;
      padding: 0
    }

    ul {
      list-style: none;
    }

    .container {
      margin: 10px auto;
      width: 300px;
      height: 500px;
      border: 2px solid #e7e7e7;
      border-radius: 10px;
    }

    .container h4 {
      text-align: center;
      height: 50px;
      line-height: 50px;
      font-size: 24px;
      background-color: #909399;
      color: #FFF;
      border-top-right-radius: 8px;
      border-top-left-radius: 8px;

      letter-spacing: 24px;
      padding-left: 16px;

      /* font: bold 24px "Microsoft YaHei"; */
      text-shadow: 1px 1px rgba(197, 223, 248, 0.8),
        2px 2px rgba(197, 223, 248, 0.8),
        3px 3px rgba(197, 223, 248, 0.8),
        4px 4px rgba(197, 223, 248, 0.8),
        5px 5px rgba(197, 223, 248, 0.8),
        6px 6px rgba(197, 223, 248, 0.8);
    }

    /* tab */
    #coupon {
      border-top: 2px solid #e7e7e7;
      height: 26px;
      border-bottom: 2px solid #e7e7e7;
    }

    #coupon>li {
      float: left;
      display: inline-block;
      width: 100px;
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      color: rgb(177, 175, 175);
      box-sizing: border-box;
      text-align: center;
      cursor: pointer;
      margin-top: -2px;
      margin-bottom: -2px;
    }

    #coupon>li:first-child {
      border-left: 0;
      border-right: 0;
    }

    #coupon>li:last-child {
      border-left: 0;
      border-right: 0;
    }

    #coupon .active {
      border: none;
      background: #409eff;
      border-radius: 2px;
      color: #fff;
    }

    /* 优惠券内容 */
    #coupon-contain {
      margin: 10px 5px;
    }

    #coupon-contain>div>div {
      margin: 10px 5px;
      text-align: center;
      height: 40px;
      line-height: 40px;
      border-radius: 8px;
      background: #f56c6c;
      color: #fff;
      font-size: 14px;
    }

    /* 隐藏所有优惠券 */
    #coupon-contain>div {
      display: none;
    }

    /* 显示class为show的元素 */
    #coupon-contain>.show {
      display: block;
    }

    #coupon-contain>div:first-child>div {
      background: #67c23a;
    }

    #coupon-contain>div:last-child>div {
      background: #909399;
    }
  </style>

  <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
  <script>
    $(function () {
      var $coupon_tab = $("#coupon>li");
      var $coupon_contain = $('#coupon-contain>div');
      var index = 0;

      $coupon_tab.click(function () {
        // 移除tab中class的active属性
        $($coupon_tab[index]).removeClass('active');
        // 移除优惠券中class的active属性
        $($coupon_contain[index]).removeClass('show');
        index = $(this).index();
        // 添加tab中class的active属性
        $(this).addClass('active');
        // 添加优惠券中class的active属性
        $($coupon_contain[index]).addClass('show');
      });
    });
  </script>
</head>

<body>
  <div class="container">
    <h4>优惠券</h4>
    <ul id="coupon">
      <li class="active">未使用</li>
      <li>已使用</li>
      <li>已过期</li>
    </ul>
    <div id="coupon-contain">
      <div id="coupon-unused" class="show">
        <div>未使用的优惠券</div>
        <div>未使用的优惠券</div>
        <div>未使用的优惠券</div>
      </div>
      <div id="coupon-used" class="hide">
        <div>已使用的优惠券</div>
        <div>已使用的优惠券</div>
        <div>已使用的优惠券</div>
      </div>
      <div id="coupon-expired" class="hide">
        <div>已过期的优惠券</div>
        <div>已过期的优惠券</div>
        <div>已过期的优惠券</div>
      </div>
    </div>
  </div>
</body>

</html>
相关推荐
GISer_Jing几秒前
ByteDance——jy真题
前端·javascript·面试
睡美人的小仙女1271 分钟前
浏览器为何屏蔽本地文件路径?
前端
真的想不出名儿2 分钟前
Vue 中 props 传递数据的坑
前端·javascript·vue.js
FIN66683 分钟前
昂瑞微:深耕射频“芯”赛道以硬核实力冲刺科创板大门
前端·人工智能·科技·前端框架·信息与通信·智能
阳光阴郁大boy4 分钟前
星座运势网站技术解析:从零打造现代化Web应用
前端·javascript
烛阴17 分钟前
武装你的Python“工具箱”:盘点10个你必须熟练掌握的核心方法
前端·python
sorryhc33 分钟前
如何设计一个架构良好的前端请求库?
前端·javascript·架构
lvchaoq1 小时前
react 修复403页面无法在首页跳转问题
前端·javascript·react.js
郝开1 小时前
6. React useState基础使用:useState修改状态的规则;useState修改对象状态的规则
前端·javascript·react.js
Codigger官方2 小时前
Linux 基金会牵头成立 React 基金会:前端开源生态迎来里程碑式变革
linux·前端·react.js