div+css实现滑块开关点击切换效果代码

代码语言:html

所属分类:其他

代码描述:div+css实现滑块开关点击切换效果代码

代码标签: div css 滑块 开关 点击 切换

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

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

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

  
<style>
html, body {
    height: 100%;
}
body {
    display: flex;
    justify-content: center;
    background: rgb(244 246 248);
    background:  linear-gradient(35deg, rgb(16 15 16) 0%, rgb(32 31 32) 100%);
    margin: 0;
}
.footer{
position: absolute;
bottom: 0;
right: 0;
font-family: monospace;
color: #888;
padding: 10px;
font-size: 12px;
}
.footer a { color: #888; }
#noise-svg {
    height: 100%;
    width: 100%;
    opacity: 0.05;
    z-index: 100;
    pointer-events: none;
}
#noise-svg #noise-rect {
    width: 100vw;
    height: 100vh;
}
.container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    margin: auto;
    width: 480px;
    height: 130px;
    border-radius: 100px;
    background: rgb(7, 7, 7);
    cursor: pointer;
    transition: box-shadow 0.4s ease;
}
.container.on {
    box-shadow: 
    -2px -2px 4px 4px rgba(7, 7, 7, 0.5),
    -8px 0 4px 4px rgba(7, 7, 7, 0.5),
    -8px 0 3px 1px rgba(0, 255, 0, 0.2),
    4px 0 4px 4px rgba(7, 7, 7, 1),
    -3px 5px 3px 0 rgb(79 81 79),
    8px 3px 2px 0 rgb(79 81 79),
    inset 0 0 3px 1px rgba(0, 255, 0, 0.5),
    inset 0 0 24px 0 rgba(0, 255, 0, 0.5);
}
.container.off {
    box-shadow: 
    -2px -2px 4px 4px rgba(7, 7, 7, 0.5),
    -8px 0 4px 4px rgba(7, 7, 7, 0.5),
    8px 0 3px 1px rgba(255, 0, 0, 0.2),
    4px 0 4px 4px rgba(7, 7, 7, 1),
    -3px 5px 3px 0 rgb(79 81 79),
    8px 3px 2px 0 rgb(79 81 79),
    inset 0 0 3px 1px rgba(255, 0, 0, 0.5),
    inset 0 0 14px 0 rgba(255, 0, 0, 0.5);
}
.toggle {
    width: 60%;
    height: 100%;
    background:linear-gradient(35deg, rgb(16 15 16) 0%, rgb(32 31 32) 100%);
    border-radius: 100px;
    position: absolute;
    transition: all 0.4s ease-in;
}
.on .toggle{
    right: 0;
    box-shadow: 
    0px 8px 8px 0 rgba(0, 0, 0, 0.4),
    inset 0px -3px 3px 0 rgba(0, 0, 0, 1),
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0