js+css实现滑块拖动日出日落效果代码

代码语言:html

所属分类:拖放

代码描述:js+css实现滑块拖动日出日落效果代码

代码标签: js css 滑块 拖动 日出 日落

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    *,
*::after,
*::before {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --icon-opacity: 0.3;
    --label: 2.75rem;
    --width: clamp(22.5rem, -0.5488rem + 87.8049vw, 35rem);
    --thumb: clamp(3rem, calc(2.28rem + 3.18vw), 3.88rem);
    --icon-size: clamp(3rem, 2.4067rem + 4.675vw, 4.8318rem);
}

body {
    min-block-size: 100vh;
    display: grid;
    place-content: center;
    background-color: hsl(198deg, 13%, 43%);
}

.container {
    display: grid;
    grid-auto-flow: column;
    grid: "sun" 1fr "slider" auto;
    place-content: center stretch;
    inline-size: var(--width);
    aspect-ratio: 16 / 9;
    gap: 1em;
}

.sun {
    grid-area: sun;
}

.icon {
    inline-size: var(--icon-size);
    block-size: var(--icon-size);
    opacity: var(--icon-opacity, 1);
    fill: #ddb300;
    transition: all 500ms cubic-bezier(0.1, 0.42, 0, 1.5);
}

.slider-container {
    grid-area: slider;
    display: flex;
    height: 1rem;
}

.slider {
    display: flex;
    flex-grow: 1;
    position: relative;
    inline-size: 100%;
    border-radius: 100vh;
    border: 2px solid #eee;
    box-shadow: 0 1px 1px 0px #fff9 inset, 0 0.5em 0.75em #0003,
        0 1.125em 1.67em 0.125em #0002;
}

.input-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    height: 100%;
    border-radius: 100vh;
    box-shadow: 0 2px 5px 0px #0006 inset, 0 -2px 4px 1px #fff8 inset;
}

.input-slider::-webkit-slider-thumb {
    background: linear-gradient(
        to bottom,
        #fff 30%,
        hsl(192deg, 3%, 68%) 75%,
        hsl(192deg 3% 46%)
    );
    border-radius: 50%;
    width: 3rem;
    aspect-ratio: 1;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 1px 1.5px #0004, 0 2px 5px #0003, 0 5px 9px #0002;
}

.input-slider::-moz-range-thumb,
.input-slider::slider-thumb {
    background: linear-gradient(
        to bottom,
        #fff 30%,
        hsl(192deg, 3%, 68%) 75%,
        hsl(192deg 3% 46%)
    );
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    /* aspect-ratio: 1; */
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 1px 1.5px #0004, 0 2px 5px #0003, 0 5px 9px #0002;
}
</style>

</head>
<body>

<section class="container">
    <div class="sun">
        <svg class="icon" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
            <path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.7.........完整代码请登录后点击上方下载按钮下载查看

网友评论0