最终效果:
在径向菜单的制作前,首先需要知道几点知识点:
Math.sin(x) x 的正玄值。返回值在 -1.0 到 1.0 之间;
Math.cos(x) x 的余弦值。返回的是 -1.0 到 1.0 之间的数;
这两个函数中的X 都是指的“弧度”而非“角度”,弧度的计算公式为: 2*PI/360*角度,使用js表示是这样的:Math.PI/180*度数(1度=180/Math.PI)
如:30° 角度 的弧度 = 2*PI/360*30
如何计算圆上任何点坐标(用于计算出子菜单相对于圆的位置)
以父容器左上角为圆点,建立坐标系
代码如下:
径向菜单的制作 * { margin: 0; padding: 0; } body { background-color: #292a38; font-family: "Microsoft Yahei"; } h1 { margin-top: 20px; text-align: center; color: #fff; } .navWrap { position: relative; width: 200px; height: 200px; margin: 50px auto; border: 2px dotted #4e5061; border-radius: 50%; } .navWrap .main-nav { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 40px; height: 40px; line-height: 40px; font-size: 12px; text-align: center; text-decoration: none; color: #fff; border-radius: 3px; text-shadow: 1px 1px 0px #000; background: #15a5f3; cursor: pointer; } .navWrap nav { position: absolute; width: 100%; height: 100%; transform: scale(0); transition: all 0.5s ease-out; opacity: 0; } .navWrap.active nav { transform: scale(1); opacity: 1; } .navWrap nav > a{ position: absolute; width: 30px; height: 30px; background: #f44283; text-align: center; line-height: 30px; text-decoration: none; color: #fff; border-radius: 3px; text-shadow: 1px 1px 0px #000; transform: translate(-50%,-50%); } 径向动画菜单效果演示 点我
以上所述就是本文的全部内容了,希望大家能够喜欢。



