悬浮跟踪气泡滑动块效果

代码语言:html

所属分类:视觉差异

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <title>CodePen - Balloon Slider</title>

    <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto:400,500,700&amp;display=swap'>
    <style>
        #slider {
            --active: #5628EE;
            --balloon: var(--active);
            --value: #fff;
            --line: #CDD9ED;
            touch-action: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            width: 320px;
            height: 2px;
            border-radius: 1px;
            background: var(--line);
            position: relative;
        }
        #slider .noUi-connects .noUi-connect {
            background: var(--active);
        }
        #slider .noUi-handle:before, #slider .noUi-handle:after {
            border-radius: 20px;
            -webkit-transform: scale(var(--s));
            transform: scale(var(--s));
            transition: border-radius .3s ease, -webkit-transform .3s ease;
            transition: transform .3s ease, border-radius .3s ease;
            transition: transform .3s ease, border-radius .3s ease, -webkit-transform .3s ease;
        }
        #slider .noUi-handle:before {
            --s: .5;
            background: var(--active);
        }
        #slider .noUi-handle:after {
            --s: .2;
            background: #fff;
        }
        #slider .noUi-handle.noUi-active:before {
            --s: 1;
        }
        #slider .noUi-handle.noUi-active:after {
            --s: 1;
        }
        #slider .balloon {
            --o: 0;
            --s: 0;
            --y: 0;
            --r: 0deg;
            width: 52px;
            height: 68px;
            pointer-events: none;
            position: absolute;
            z-index: 5;
            left: -26px;
            bottom: 0;
            -webkit-transform-origin: 50% 100%;
            transform-origin: 50% 100%;
        }
        #slider .balloon > div {
            width: 52px;
            height: 68px;
            -webkit-transform-origin: 50% 100%;
            transform-origin: 50% 100%;
            opacity: var(--o);
            -webkit-transform: scale(var(--s)) translate(0, var(--y)) rotate(var(--r));
            transform: scale(var(--s)) translate(0, var(--y)) rotate(var(--r));
            transition: opacity .4s ease, -webkit-transform .4s ease;
            transition: transform .4s ease, opacity .4s ease;
            transition: transform .4s ease, opacity .4s ease, -webkit-transform .4s ease;
        }
        #slider .balloon > div:before, #slider .balloon > div:after {
            content: '';
            display: block;
        }
        #slider .balloon > div:before {
            width: 52px;
            height: 52px;
            border-radius: 60%;
            border-bottom-left-radius: 480%;
            border-bottom-right-radius: 480%;
            border-top-left-radius: 480%;
            -webkit-transform: rotate(135deg);
            transform: rotate(135deg);
            background: var(--balloon);
        }
        #slider .balloon > div:after {
            content: attr(data-value);
            font-family: 'Roboto', Arial;
            font-size: 14px;
            font-weight: 500;
            color: var(--value);
            position: absolute;
            left: 0;
            right: 0;
            top: 16px;
            line-height: 24px;
            text-align: center;
        }
        #slider .balloon > div svg {
            display: block;
            width: 8px;
            height: 6px;
            fill: var(--balloon);
            position: absolute;
            left: 22px;
            bottom: 0;
        }
        #slider .balloon.active {
            --o: 1;
            --s: 1;
            --y: -36px;
        }
        #slider * {
            touch-action: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }
        #slider.noUi-state-tap .noUi-connect, #slider.noUi-state-tap .noUi-origin {
            transition: -webkit-transform .3s;
            transition: transform .3s;
            transition: transform .3s, -webkit-transform .3s;
        }
        #slider .noUi-target {
            position: relative;
        }
        #slider .noUi-base,
        #slider .noUi-connects {
            position: relative;
            z-index: 1;
            width: 100%;
            height: 100%;
        }
        #slider .noUi-origin,
        #slider .noUi-connect {
            position: absolute;
            will-change: transform;
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
            top: 0;
            left: 0;
            z-index: 1;
        }
        #slider .noUi-connects {
            overflow: hidden;
            z-index: 0;
            border-radius: 1px;
        }
        #slider .noUi-connects .noUi-connect {
            width: 100%;
            height: 100%;
        }
        #slider .noUi-handle {
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            position: absolute;
            outline: none;
            cursor: pointer;
            width: 40px;
            height: 40px;
            left: 12px;
            top: -19px;
        }
        #slider .noUi-handle:before, #slider .noUi-handle:after {
            content: '';
            position: absolute;
        }
        #slider .noUi-handle:before {
            left: 0;
            top: 0;
            width: 40px;
            height: 40px;
        }
        #slider .noUi-handle:after {
            left: 2px;
            top: 2px;
            width: 36px;
            heigh.........完整代码请登录后点击上方下载按钮下载查看

网友评论0