svg+css+js实现树状checkbox开关效果代码
代码语言:html
所属分类:其他
代码描述:svg+css+js实现树状checkbox开关效果代码
代码标签: svg css js 树状 checkbox 开关
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
*,
*:after,
*:before {
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
min-height: 100vh;
font-family: 'SF Pro Text', 'SF Pro Icons', 'AOS Icons', 'Helvetica Neue',
Helvetica, Arial, sans-serif, system-ui;
}
html {
color-scheme: light dark;
}
[data-theme='light'] {
color-scheme: light only;
}
[data-theme='dark'] {
color-scheme: dark only;
}
body::before {
--size: 45px;
--line: color-mix(in lch, canvasText, transparent 70%);
content: '';
height: 100vh;
width: 100vw;
position: fixed;
background: linear-gradient(
90deg,
var(--line) 1px,
transparent 1px var(--size)
)
50% 50% / var(--size) var(--size),
linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
var(--size) var(--size);
-webkit-mask: linear-gradient(-20deg, transparent 50%, white);
mask: linear-gradient(-20deg, transparent 50%, white);
top: 0;
transform-style: flat;
pointer-events: none;
z-index: -1;
}
:where(.x-link):is(:hover, :focus-visible) {
opacity: 1;
}
/* Utilities */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
[for] {
--active: 0;
cursor: pointer;
height: clamp(24px, var(--size) * 0.5px, 150px);
width: clamp(48px, var(--size) * 1px, 300px);
border-radius: 50%;
position: relative;
transition: background-color 0.25s;
}
[for]:is(:hover, :has(+ :focus-visible)) {
background: color-mix(in lch, canvas, canvasText 15%);
}
.tree {
overflow: visible !important;
width: 60%;
position: absolute;
bottom: 50%;
left: 50%;
translate: -50% 10%;
}
:root:has(#tree:focus-visible) [for='tree'] {
outline: 2px dashed green;
}
[for='tree'] {
--ease: linear(
0 0%,
0.5007 7.21%,
0.7803 12.29%,
0.8883 14.93%,
0.9724 17.63%,
1.0343 20.44%,
1.0754 23.44%,
1.0898 25.22%,
1.0984 27.11%,
1.1014 29.15%,
1.0989 31.4%,
1.0854 35.23%,
1.0196 48.86%,
1.0043 54.06%,
0.9956 59.6%,
0.9925 68.11%,
1 100%
);
}
:root:has(#tree:checked) [for='tree'] {
--active: 1;
--ease: linear(
0 0%,
0.0075 31.89%,
0.0044 40.4%,
-0.0043 45.94%,
-0.0196 51.14%,
-0.0854 64.77%,
-0.0989 68.6%,
-0.1014 70.85%,
-0.0984 72.89%,
-0.0898 74.78%,
-0.0754 76.56%,
-0.0343 79.56%,
0.0276 82.37%.........完整代码请登录后点击上方下载按钮下载查看
网友评论0