<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>圆形导航-径向收缩菜单</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
}
.menu{
position: relative;
width: 300px;
height: 300px;
/* background-color: #00FF00; */
display: flex;
justify-content: center;
align-items: center;
}
.menu li{
position: absolute;
left: 0;
list-style: none;
transform-origin: 150px;
transform: 0.5s;
transition-delay: calc(0.05s*var(--i));
transform: rotate(0deg) translateX(150px);
}
.menu.active li{
transform: rotate(calc(360deg/8*var(--i)));
}
.toggle{
position: absolute;
width: 80px;
height: 80px;
background-color: white;
display: flex;
justify-content: center;
align-items: center;
z-index: 10000;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 0px 4px rgba(0,0,0,0.15);
font-size: 2em;
transition:transform 1s;
}
.menu.active .toggle{
transform: rotate(315deg);
}
ion-icon{
width: 40px;
height: 40px;
}
</style>
</head>
<body>
<div class="menu">
<div class="toggle"><ion-icon name="add-outline"></ion-icon></div>
<li style="--i:0">
<a href="#"><ion-icon name="home-outline"></ion-icon></a>
</li>
<li style="--i:1">
<a href="#"><ion-icon name="people-outline"></ion-icon></a>
</li>
<li style="--i:2">
<a href="#"><ion-icon name="settings-outline"></ion-icon></a>
</li>
<li style="--i:3">
<a href="#"><ion-icon name="alarm-outline"></ion-icon></a>
</li>
<li style="--i:4">
<a href="#"><ion-icon name="color-palette-outline"></ion-icon></a>
</li>
<li style="--i:5">
<a href="#"><ion-icon name="mail-open-outline"></ion-icon></a>
</li>
<li style="--i:6">
<a href="#"><ion-icon name="game-controller-outline"></ion-icon></a>
</li>
<li style="--i:7">
<a href="#"><ion-icon name="warning-outline"></ion-icon></a>
</li>
</div>
<!-- 引入图标 -->
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<script>
let toggle = document.querySelector('.toggle');
let menu = document.querySelector('.menu');
toggle.onclick = function(){
menu.classList.toggle('active')
}
</script>
</body>
</html>
效果如图: