div+css实现立体圆柱滚动开关效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现立体圆柱滚动开关效果代码

代码标签: div ss 立体 圆柱 滚动 开关

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

<!DOCTYPE html>
<html lang="en" >

<head>
 
<meta charset="UTF-8">
 


 
<style>
* {
        border: 0;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
}
:root {
        --hue: 223;
        --bg: hsl(var(--hue),10%,90%);
        --fg: hsl(var(--hue),10%,10%);
        --trans-dur: 0.4s;
        font-size: calc(40px + (60 - 40) * (100vw - 320px) / (2560 - 320));
}
body,
input {
        color: var(--fg);
        font: 1em/1.5 Helvetica, sans-serif;
}
body {
        background-color: var(--bg);
        display: flex;
        height: 100vh;
        transition:
                background-color var(--trans-dur),
                color var(--trans-dur);
}
.switch,
.switch__input,
.switch__handle-sides,
.switch__handle-side,
.switch__handle-labels,
.switch__handle-label,
.switch__handle-texture {
        display: block;
}
.switch,
.switch__input {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
}
.switch {
        margin: auto;
        position: relative;
        width: 3em;
        height: 3em;
}
.switch__input {
        background-color: hsl(var(--hue),10%,95%);
        border-radius: 0.25em;
        box-shadow:
                0.125em 0.125em 0.125em hsl(0,0%,100%) inset,
                -0.125em -0.125em 0.125em hsl(var(--hue),10%,85%) inset,
                0.125em 0.125em 0.375em hsl(var(--hue),10%,70%);
        outline: transparent;
        position: relative;
        width: 100%;
        height: 100%;
        transition:
                background-color var(--trans-dur),
                box-shadow var(--trans-dur);
        -webkit-appearance: none;
        appearance: none;
}
.switch__input:before {
        border-radius: inherit;
        box-shadow: 0 0 0 max(0.125em,1px) hsla(var(--hue),90%,50%,0);
        content: "";
        display: block;
        position: absolute;
        inset: 0;
        transition: box-shadow 0.15s linear;
}
.switch__input:focus-visible:before {
        box-shadow: 0 0 0 max(0.125em,1px) hsla(var(--hue),90%,50%,1);
}
.switch__handle,
.switch__handle-sides,
.switch__handle-side,
.switch__handle-labels,
.switch__handle-label {
        position: absolute;
}
.switch__handle,
.switch__handle-label {
        transition: transform var.........完整代码请登录后点击上方下载按钮下载查看

网友评论0