纯css实现tab选项卡切换动画

代码语言:html

所属分类:选项卡

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

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

    <title>nezt</title>

    <style>
        * {
            font-family: 'Work Sans', sans-serif;
        }

        html, body {
            height: 100%;
            color: #1a1b1c;
        }

        label, a {
            cursor: pointer;
            user-select: none;
            text-decoration: none;
            display: inline-block;
            color: inherit;
            transition: border 0.2s;
            border-bottom: 5px solid rgba(142, 68, 173, 0.2);
            padding: 3px 2px;
        }
        label:hover, a:hover {
            border-bottom-color: #9b59b6;
        }

        .layout {
            display: grid;
            height: 100%;
            width: 100%;
            overflow: hidden;
            grid-template-rows: 50px 1fr;
            grid-template-columns: 1fr 1fr 1fr;
        }

        input[type="radio"] {
            display: none;
        }

        label.nav {
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            border-bottom: 2px solid #8e44ad;
            background: #ecf0f1;
            user-select: none;
            transition: background 0.4s, padding-left 0.2s;
            padding-left: 0;
        }
        input[type="radio"]:checked + .page + label.nav {
            background: #9b59b6;
            color: #ffffff;
            padding-left: 20px;
        }
        input[type="radio"]:checked + .page + label.nav span {
            padding-left: 20px;
        }
        input[type="radio"]:checked + .page + label.nav svg {
            opacity: 1;
        }
        label.nav span {
            padding-left: 0px;
            position: relative;
        }
        label.nav svg {
            left: 0;
            top: -3px;
            position: absolute;
            width: 15px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .page {
            grid-column-start: 1;
            grid-row-start: 2;
            grid-column-end: span3;
            padding: 0px 20px;
            display: flex;
            align-items: center;
        }

        .page-contents > * {
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.2s, transform 0.2s;
        }
        .page-contents > *:nth-child(1) {
            transition-delay: 0.4s;
        }
        .page-contents > *:nth-child(2) {
            transition-delay: 0.6s;
        }
        .page-contents > *:nth-child(3) {
            transition-delay: 0.8s;
        }
        .page-contents > *:nth-child(4) {
            transition-delay: 1s;
        }
        .page-contents > *:nth-child(5) {
            transition-delay: 1.2s;
        }
        .page-contents > *:nth-child(6) {
            transition-delay: 1.4s;
        }
        .page-contents > *:nth-child(7) {
            transition-delay: 1.6s;
        }
        .page-contents > *:nth-child(8) {
            transition-delay: 1.8s;
        }
        .page-contents > *:nth-child(9) {
            transition-delay: 2s;
        }
        .page-contents > *:nth-child(10) {
            transition-delay: 2.2s;
        }
        .page-contents > *:nth-child(11) {
            transition-delay: 2.4s;
        }
        .page-contents > *:nth-child(12) {
            transition-delay: 2.6s;
        }
        .page-contents > *:nth-child(13) {
            transition-delay: 2.8s;
        }
        .page-contents > *:nth-child(14) {
            transition-delay: 3s;
        }
        .page-contents > *:nth-child(15) {
            transition-delay: 3.2s;
        }
        .page-contents > *:nth-child(16) {
            transition-delay: 3.4s;
        }
        .page-contents > *:nth-child(17) {
            transition-delay: 3.6s;
        }
        .page-contents > *:nth-child(18) {
            transition-delay: 3.8s;
        }
        .page-contents > *:nth-child(19) {
            transition-delay: 4s;
        }
        .page-contents > *:nth-child(20) {
            transition-delay: 4.2s;
        }

        input[type="radio"] + .page {
            transition: transform 0.2s;
            transform: translateX(100%);
        }

        input[type="radio"]:checked + .page {
            tra.........完整代码请登录后点击上方下载按钮下载查看

网友评论0