手写滑动菜单

代码比较简单,不再做过多介绍了
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"> 
	<title>手写滑动菜单</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
</head>
<style>
    .body {
        background: #607d8b!important;
    }
    .mindiv {
        width: 600px;
        height: 400px;
        margin: 100px auto;
        box-shadow: 0 0 10px rgba(0, 0, 0, .1);
    }
    .slidebox {
        position: relative;
        overflow: hidden;
        height: 45px;
    }
    .slideboxitem {
        padding: 6px 15px;
        height: 36px;
        text-align: center;
        font-size: 14px;
        line-height: 36px;
        font-weight: 600;
        color: #607d8b;
        cursor: pointer;
        float: left;
    }
    .slidebottom {
        height: 3px;
        position: absolute;
        bottom: 0;
        left: 0;
        transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
        background: #607d8b;
    }
</style>
<body>
<div class="mindiv">
    <div class="slidebox">
        <div class="slideboxitem"></div>
        <div class="slideboxitem">选项二</div>
        <div class="slideboxitem">选项三选项三</div>
        <div class="slideboxitem">选项四</div>
        <div class="slidebottom"></div>
    </div>
</div>
</body>
<script>
	//初始位置
    var bottomobject = {
        left: '15px',
        width: $(".slideboxitem").eq(0).width()
    }
    $(".slidebottom").css({"width": bottomobject.width,"left": bottomobject.left});
    //设置显示位置
    $(".slideboxitem").on("click", function() {
        var width = $(this).width();
        var left = $(this).offset().left - $(".mindiv").offset().left + 15;
        $(".slidebottom").css({"width": width,"left": left});
    })
</script>
</html>

实现效果

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值