当前位置:网站首页>Rotate navigation bar
Rotate navigation bar
2022-06-10 21:29:00 【Zangxiaochuan】
design sketch

JS
import React, {
useState } from 'react';
import styles from './style.less'
const index = () =>
{
const [navData, setNavData] = useState([
{
name: ' Wen Brigade ', id: 1, rotate: 0 },
{
name: ' health ', id: 2, rotate: 60 },
{
name: ' education ', id: 3, rotate: 120 },
{
name: ' Technology ', id: 4, rotate: 180 },
{
name: ' Hip hop ', id: 5, rotate: 240 },
{
name: ' The people's livelihood ', id: 6, rotate: 300 },
])
const [isShow, setIsShow] = useState(true)
const [mouse, setMouse] = useState(false)
const [rotate, setRotate] = useState(0)
const click = () =>
{
setIsShow(!isShow)
}
const handleMouse = (flag) =>
{
return () =>
{
setMouse(flag)
}
}
const aaa = (index) =>
{
console.log(index - rotate);
setRotate(index)
}
return (
<div style={
{
transform: `rotate(-${
rotate}deg)`, transition: 'all 1s' }} className={
styles.container}>
<nav className={
styles.menu} >
<div
style={
{
transform: `rotate(${
rotate}deg)`, transition: 'all 1s' }}
onMouseEnter={
handleMouse(true)}
onMouseLeave={
handleMouse(false)} onClick={
click} className={
styles.togglerContainers}>
<div className={
mouse ? styles.menu_toggler_active : styles.menu_toggler}></div>
</div>
<ul >
{
navData.map((data, index) => (
<li style={
isShow ? {
transform: `rotate(${
data.rotate}deg) translateX(-110px)` } : null} key={
index} className={
`${
styles.menu_item} ${
isShow && styles.menu_item_active} `} >
{
/* Font problem Slightly modified later ~ For most of the day */}
<a style={
{
transform: `rotate(${
data.rotate - rotate}deg)`, transition: 'all 1s' }} onClick={
() => {
aaa(data.rotate) }}>{
data.name}</a>
</li>
))
}
</ul>
</nav>
</div >
);
};
export default index
CSS
.container {
background: #ed6ea0;
width: 400px;
height: 400px;
border-radius: 50%;
.togglerContainers {
position: absolute;
display: block;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 40px;
height: 40px;
z-index: 2;
cursor: pointer;
}
.menu_toggler {
width: 100%;
height: 5px;
display: block;
z-index: 1;
border-radius: 2.5px;
background: rgba(255, 255, 255, 0.7);
transition: transform 0.5s, top 0.5s;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.menu_toggler_active {
width: 100%;
height: 5px;
display: block;
z-index: 1;
border-radius: 2.5px;
background: rgba(255, 255, 255, 1);
transition: transform 0.5s, top 0.5s;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
&::before, &::after {
width: 40px;
height: 5px;
display: block;
z-index: 1;
border-radius: 2.5px;
background: rgba(255, 255, 255, 1);
transition: transform 0.5s, top 0.5s;
content: "";
position: absolute;
left: 0;
}
&::after {
top: -10px;
}
&::before {
top: 10px;
}
}
.menu_toggler::before, .menu_toggler::after {
width: 40px;
height: 5px;
display: block;
z-index: 1;
border-radius: 2.5px;
background: rgba(255, 255, 255, 0.7);
transition: transform 0.5s, top 0.5s;
content: "";
position: absolute;
left: 0;
}
.menu_toggler::before {
top: 10px;
}
.menu_toggler::after {
top: -10px;
}
// Active button .menu_item_active {
opacity: 1 !important;
}
.menu_item_active:nth-child(1) {
transform: rotate(0deg) translateX(-110px);
}
.menu_item_active:nth-child(2) {
transform: rotate(60deg) translateX(-110px);
}
.menu_item_active:nth-child(3) {
transform: rotate(120deg) translateX(-110px);
}
.menu_item_active:nth-child(4) {
transform: rotate(180deg) translateX(-110px);
}
.menu_item_active:nth-child(5) {
transform: rotate(240deg) translateX(-110px);
}
.menu_item_active:nth-child(6) {
transform: rotate(300deg) translateX(-110px);
}
.menu_item_active:nth-child(1) a {
transform: rotate(0deg);
}
.menu_item_active:nth-child(2) a {
transform: rotate(-60deg);
}
.menu_item_active:nth-child(3) a {
transform: rotate(-120deg);
}
.menu_item_active:nth-child(4) a {
transform: rotate(-180deg);
}
.menu_item_active:nth-child(5) a {
transform: rotate(-240deg);
}
.menu_item_active:nth-child(6) a {
transform: rotate(-300deg);
}
.menu_item {
position: absolute;
display: block;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 80px;
height: 80px;
opacity: 0;
transition: 0.5s;
}
.menu_item a {
display: block;
width: inherit;
height: inherit;
line-height: 80px;
color: rgba(255, 255, 255, 0.7);
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
text-align: center;
text-decoration: none;
font-size: 16px;
transition: 0.2s;
font-weight: 700;
&:hover {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
color: #fff;
background: rgba(255, 255, 255, 0.3);
font-size: 18px;
}
}
}
边栏推荐
- 数据库系统概论 ---- 第一章 -- 绪论(重要知识点)
- H265 Nalu type judgment and SPS data analysis
- LeetCode 进阶之路 - 删除排序数组中的重复项
- As a programmer, is it really that important for the underlying principles?
- Use DAP link to download the executable file separately to the mm32f5 microcontroller
- Whether there is a simple path from brute force method /u to V
- Brute force method / task assignment
- 信号与系统复习1
- Theoretical basis of distributed services
- Quick start to elastic job, three minutes to experience distributed scheduled tasks
猜你喜欢

Vissim仿真快速入门

Quick start to VISSIM simulation

Redis cache breakdown

Pytorch deep learning -- convolution operation and code examples

「运维有小邓」自助帐户解锁工具

What should be paid attention to when designing Multilayer PCB?

連接mysql報錯 errorCode 1129, state HY000, Host ‘xxx‘ is blocked because of many connection errors

冷酸灵,一个国产品牌IPO的30年曲折史

Fast Planner - detailed explanation of kinetic astar

Meetup Preview: introduction to the new version of linkis and the application practice of DSS
随机推荐
Use DAP link to download the executable file separately to the mm32f5 microcontroller
LeetCode 进阶之路 - 字符串中的第一个唯一字符
CCF class a conference or journal - regression related papers
Obtained network time + time zone (+8)
Mba-day21 linear programming problem
Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading
自制Table表格
Kcon 2022 topic public selection is hot! Don't miss the topic of "favorite"
[untitled] broken item
蛮力法/任务分配
Can you still have a wonderful life if you are laid off at the age of 35?
Shell implements SSH login and executes commands
旋转导航栏
"O & M youxiaodeng" self service account unlocking tool
Read the source code of micropyton - add the C extension class module (4)
LeetCode 进阶之路 - 136.只出现一次的数字
Monitoring is easy to create a "quasi ecological" pattern and empower Xinchuang to "replace"
A small case with 666 times performance improvement illustrates the importance of using indexes correctly in tidb
Quick start to VISSIM simulation
冷酸灵,一个国产品牌IPO的30年曲折史