js实现一个canvas四色圆点转动背景效果代码

代码语言:html

所属分类:背景

代码描述:js实现一个canvas四色圆点转动背景效果代码

代码标签: canvas 四色 圆点 转动 背景 效果

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

<html lang="en">
<head>

    <meta charset="UTF-8">




    <style>
:root {
        --black: #101820;
    }

        body {
            align-content: start;
            box-sizing: border-box;
            display: grid;
            font-family: sans-serif;
            font-weight: bold;
            min-height: 100vh;
            grid-template-columns: minmax(280px, 485px) 1fr;
            letter-spacing: 0.03em;
            line-height: 1;
            padding: 16px;
            text-align: center;
        }
        body *:focus:not(:focus-visible) {
            outline: none;
        }

        canvas#webgl {
            left: 0;
            position: fixed;
            top: 0;
            z-index: 0;
        }

        button {
            appearance: none;
            background: white;
            border: none;
            border-radius: 0;
            color: var(--black);
            cursor: pointer;
            font-family: inherit;
            font-weight: inherit;
            font-size: inherit;
            letter-spacing: inherit;
            line-height: inherit;
        }

        .toggle {
            background: white;
            box-shadow: 0 0 32px rgba(17, 25, 33, 0.5);
            position: relative;
            z-index: 1;
        }
        .toggle[aria-expanded=true] .toggle__content {
            max-height: 800px;
            opacity: 1;
            transition-delay: 0.2s, 0s, 0s;
            transition-duration: 0.4s, 0.4s, 0s;
            visibility: visible;
        }

        .toggle__button {
            --space: 8px;
            align-items: center;
            display: flex;
            font-size: 1.2rem;
            justify-content: center;
            padding: calc(var(--space) *3);
            position: relative;
            width: 100%;
        }

        .toggle__icon {
            position: absolute;
            top: 50%;
            right: calc(var(--space) *2);
            transform: translateY(-50%);
        }

        .toggle__content {
            max-height: 0;
            opacity: 0;
            transition-delay: 0s, 0.2s, 0.6s;
            transition-duration: 0.2s, 0.4s, 0s;
            transition-property: opacity, max-height, visibility;
            visibility: hidden;
        }
        .toggle__content::before {
            background-color: var(--black);
            content: "";
            display: block;
            height: 1px;
            margin: auto;
            width: 94px;
        }

        .color-picker {
            display: grid;
            padding: 20px 20px 16px;
            position: relative;
            gap: 16px;
            z-index: 1;
        }

        .color-picker__canvas-wrap {
            justify-self: center;
            position: relative;
            touch-action: none;
            width: 73%;
        }

        .color-picker__canvas {
            cursor: grab;
            display: block;
            width: 100%;
        }
        .color-picker__canvas:active {
            cursor: grabbing;
        }

        .color-picker__selected {
            border: 1px solid #101820;
            color: #6F747B;
            padding: 20px;
        }

        .color-picker__inputs {
            margin: 0;
            padding: 0;
            line-height: 1;
            list-style-type: none;
        }

        .color-picker__item {
            display: flex;
            margin: 0;
        }

        .color-picker__input-wrap {
            align-items: center;
            background-color: var(--fill);
            display: flex;
            flex: 0 1 85%;
            height: 32px;
            position: relative;
        }
        .color-picker__input-wrap::before {
            background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 50%, rgba(255, 255, 255, 0) 51%, rgba(255, 255, 255, 0.9) 100%);
            content: "";
            height: 100%;
            left: 0;
            position: absolute;
            top: 0;
            width: 100%;
        }

        .color-picker__input {
            --size: 14px;
            --scale: 1;
            --active-scale: 1.3;
            appearance: none;
            background: rgba(255, 255, 255, 0);
            flex: 1;
            height: 2px;
            margin: 0 16px;
            outline: none;
            padding: 0;
            position: relative;
        }
        .color-picker__input::-webkit-slider-thumb {
            appearance: none;
            background: var(--modified-fill);
            height: var(--size);
            border-radius: 50%;
            border: 2px solid white;
            box-shadow: 0 0 0 2px black;
            cursor: pointer;
            transform: scale(var(--scale));
            transition: transform 0.2s;
            width: var(--size);
        }
        .color-picker__input::-webkit-slider-thumb:hover {
            --scale: var(--active-scale);
        }
        .color-picker__input:hover, .color-picker__input:active, .color-picker__input:focus {
            background: white;
        }
        .color-picker__input:focus::-webkit-slider-thumb {
            --scale: 1.3;
        }
        .color-picker__input:focus::-moz-range-thumb {
            --scale: 1.3;
        }
        .color-picker__input::-moz-range-thumb {
            appearance: none;
            background: var(--modified-fill);
            height: var(--size);
            border-radius: 50%;
            border: 2px solid white;
            box-shadow: 0 0 0 2px black;
            cursor: pointer;
            transform: scale(var(--scale));
            transition: transform 0.2s;
            width: var(--size);
        }
        .color-picker__input::-moz-range-thumb:hover {
           .........完整代码请登录后点击上方下载按钮下载查看

网友评论0