css+div实现悬浮文字旋转的导航菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:css+div实现悬浮文字旋转的导航菜单效果代码,鼠标悬浮,文字转圈圈。

代码标签: css div 悬浮 文字 旋转 导航 菜单

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

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

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

  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
  
  
  
<style>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
/* reset button */
button {
    appearance: none;
    background-color: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    text-decoration: none;
    text-transform: none;
    line-height: normal;
    overflow: visible;
}

body{
    min-height: 100svh;
    background-color: rgb(15, 23, 42);
    color: white;
    display: grid;
    place-content: center;
    font-size: 1rem;
    font-family: system-ui;
}

nav {
    --_clr-txt: rgb(255, 255, 255);
    --_clr-txt-svg: rgb(147, 158, 184);
    --_ani-speed: 6s; /* speed of rotating text */

    display: flex;
    gap: 1rem;
    font-size: 1.4rem;
}
nav>button {
    position: relative;
    display: grid;
    place-content: center;
    grid-template-areas: 'stack';
    padding: 0 1.5rem;
    text-transform: uppercase;
    font-weight: 300;
}

/* place button items on top of each other */
nav>button>span {
    transition: all 300ms ease-in-out;
    grid-area: stack;
}
/* nav icon */
nav>button>span:last-of-type {
    margin-top: 0.25rem;
    transform: scale(0);
    transition-delay: 0ms;
    border-radius: 50%;
}
/* hover - hide text */
nav>button:focus-visible>span:first-of-type,
nav>button:hover>span:first-of-type {
    transform: scale(0);
}
/* hover - reveal icon */
nav>button:focus-visible>span:last-of-type,
nav>button:hover>span:last-of-type {
    transform: scale(1);
}

/* nav SVG circular text*/
nav>button>svg {
    position: absolute;
    width: 200px;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center;
    opacity: 0;
    text-transform: uppercase;
    transition: all 300ms ease-in-out;
    color: var(--_clr-txt-svg);
}
/* hover - reveal rotating SVG */
nav>button:focus-visible>svg,
nav>button:hover>svg {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    transition-delay: 150ms;
    transition: all 300ms ease-in-out;
}

/* rotating text within SVG */
button text {
    transform-origin: center;
    animation: rotate var(--_ani-speed) linear infinite;
}
@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
</style>


  
</head>

<body translate="no">
  <nav>
  <button type="button" title="Home">
    <s.........完整代码请登录后点击上方下载按钮下载查看

网友评论0