SOURCE

console 命令行工具 X clear

                    
>
console
const nav = document.querySelector('nav')
const toggle = nav.querySelector('.toggle')

toggle.onclick = () => {
    nav.classList.toggle('active')
}

const onDrag = ({movementY}) => {
    const navStyle = window.getComputedStyle(nav)
    const navTop = parseInt(navStyle.top)
    const navH = parseInt(navStyle.height)
    const winH = window.innerHeight

    nav.style.top = navTop > 0 ? `${navTop + movementY}px` : '1px'
    if (navTop > winH - navH) {
        nav.style.top = `${winH - navH}px`
    }
}
nav.addEventListener('mousedown', () => {
    nav.addEventListener('mousemove', onDrag)
})
nav.addEventListener('mouseup', () => {
    nav.removeEventListener('mousemove', onDrag)
})
nav.addEventListener('mouseleave', () => {
    nav.removeEventListener('mousemove', onDrag)
})
<div class="main">
    <nav>
        <div class="menu">
            <dt class="toggle"><i class='bx bx-plus'></i></dt>

            <dd style="--i:0;">
                <a href="#"><i class='bx bxs-home'></i></a>
            </dd>
            <dd style="--i:1;">
                <a href="#"><i class='bx bxs-camera'></i></a>
            </dd>
            <dd style="--i:2;">
                <a href="#"><i class='bx bxs-alarm'></i></a>
            </dd>
            <dd style="--i:3;">
                <a href="#"><i class='bx bxs-map'></i></a>
            </dd>
            <dd style="--i:4;">
                <a href="#"><i class='bx bxs-cog'></i></a>
            </dd>
        </div>
    </nav>
</div>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.main {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #17a2b8;
    overflow: hidden;
}

nav {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 300px;
    /* background-color: red; */
    cursor: grab;
    position: absolute;
    top: 100px;
    right: 0;
}

.menu {
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu .toggle,
.menu dd a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.menu dd {
    position: absolute;
    opacity: 0;
    transition: all 0.6s ease;
}
nav.active .menu dd {
    opacity: 1;
    transform: rotate(calc(var(--i) * (360deg / 8))) translateY(120px);
}

.menu .toggle {
    font-size: 35px;
    color: #0e2431;
    cursor: pointer;
    z-index: 100;
    transition: all 0.6s ease;
}
nav.active .menu .toggle {
    transform: rotate(-225deg);
}

.menu dd a {
    text-decoration: none;
}
.menu dd a i {
    font-size: 24px;
    color: #0e2431;
    opacity: 0.75;
    transform: rotate(calc(var(--i) * (360deg / -8)));
    transition: 0.2s;
}
.menu dd a:hover i {
    opacity: 1;
}

本项目引用的自定义外部资源