来一篇 导航栏酷不酷!!

> 废话不多说  直接上代码  直接复制

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        ul {
            font-size: 0;
            position: relative;
            padding: 0;
            width: 100%;
            margin: 40px auto;
            user-select: none;
        }
        li {
            display: inline-block;
            width: 10%;
            height: 60px;
            background: #E95546;
            font-size: 16px;
            text-align: center;
            line-height: 60px;
            color: #fff;
            text-transform: uppercase;
            position: relative;
            overflow: hidden;
            cursor: pointer;
        }
        .slider {
            display: block;
            position: absolute;
            bottom: 0;
            left: 0;
            height: 4px;
            background: #4FC2E5;
            transition: all 0.5s;
        }
        .ripple {
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.4);
            -webkit-transform: scale(0);
            -ms-transform: scale(0);
            transform: scale(0);
            position: absolute;
            opacity: 1;
        }
        .rippleEffect {
            -webkit-animation: rippleDrop .6s linear;
            animation: rippleDrop .6s linear;
        }
        @-webkit-keyframes
        rippleDrop {  100% {
            -webkit-transform: scale(2);
            transform: scale(2);
            opacity: 0;
        }
        }
        @keyframes
        rippleDrop {  100% {
            -webkit-transform: scale(2);
            transform: scale(2);
            opacity: 0;
        }
        }
    </style>
</head>
<body>
<ul>
    <li>Tab Two</li>
    <li>Tab Two</li>
    <li>Tab Two</li>
    <li>Tab Two</li>
    <li>Tab Three</li>
    <li class="slider"></li>
</ul>
<script src="js/jquery.min.js"></script>
<script>

    $("ul li").click(function(e) {
       if ($(this).hasClass('slider')) {
            return;
        }

        var whatTab = $(this).index();
        var howFar = 10 * whatTab;

       $(".slider").css({
            left: howFar + "%"
        });

        $(".ripple").remove();

        var posX = $(this).offset().left,
            posY = $(this).offset().top,
            buttonWidth = $(this).width(),
            buttonHeight = $(this).height();

        $(this).prepend("<span class='ripple'></span>");

        if (buttonWidth >= buttonHeight) {
            buttonHeight = buttonWidth;
        } else {
            buttonWidth = buttonHeight;
        }

        var x = e.pageX - posX - buttonWidth / 2;
        var y = e.pageY - posY - buttonHeight / 2;

        $(".ripple").css({
            width: buttonWidth,
            height: buttonHeight,
            top: y + 'px',
            left: x + 'px'
        }).addClass("rippleEffect");
    });
</script>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...
    剑残阅读 9,700评论 0 8
  • 本书介绍 你是不是对Django的学习感到迷茫?是不是对网上零星的教程感到绝望?是不是苦于没有可以迅速上手的实例而...
    阡陌3536阅读 1,334评论 0 0
  • 你一定有这样的经历 当你满心欢喜地呼喊 主子的名字时,它们 对此根本毫无反应!
    o猫咪不吃鱼o阅读 1,010评论 0 10
  • 昨晚接儿子的时候 班主任老师向我告了一状,声泪俱下、绘声绘色地描述了儿子在外秋游时出的一系列状况: ...
    携梅阅读 335评论 13 13
  • 酸甜苦辣咸, 喜欢哪一个滋味, 你我她和他, 珍惜哪一个瞬间, 彩虹黑白灰, 适合哪一个方向。 清清楚楚明明白白,...
    行者D也阅读 212评论 0 0