效果截图:

HTML代码:

<div class="menu-wrap">
<nav>
<a href="" class="nav-item">1</a>
<a href="" class="nav-item">2</a>
<a href="" class="nav-item">3</a>
<a href="" class="nav-item">4</a>
<a href="" class="nav-item">5</a>
<a href="" class="nav-item">6</a>
<a href="" class="nav-item">7</a>
<a href="" class="nav-item">8</a>
</nav>
<a href="##" class="btn">展开</a>
</div>

CSS代码:

*{ padding:; margin:; }
body{ background-color: #333; }
a{ text-decoration:none; }
/*外部容器样式*/
.menu-wrap{
width: 200px; height: 200px; border-radius: 100%; margin:60px auto; position: relative;
}
/*导航样式*/
.menu-wrap nav{
width: 100%; height: 100%; position: absolute; opacity:; z-index:; transform: scale(0);
transition: all 1s ease;
}
/*菜单展开时样式*/
.menu-wrap .active{
opacity:; transform: scale(1);
}
/*菜单内容项样式*/
.menu-wrap nav .nav-item{
border-radius: 100%; position: absolute; display: block; width: 30px; height: 30px;
text-align: center; line-height: 30px; background-color: yellow; color: #333;
}
/*中间展开/收缩按钮样式*/
.menu-wrap .btn{
background-color: #15c2cf; border-radius: 100%; display: block; color: #fff; width: 60px;
height: 60px; line-height: 60px; text-align: center; position: absolute; left: 50%; top: 50%;
margin-left:-30px; margin-top: -30px; z-index:; border:solid 1px #000;
}

JS代码:

<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function(){
$(".btn").click(function(){
// 判断展开/收缩状态
if(!$("nav").hasClass("active")){ $(".btn").text("收缩");
$("nav").addClass("active"); var r=$(".menu-wrap").width()/2; //定义圆的半径
var startAngel=0,
endAngel=360;//设置起始、结束度数
var total=$(".nav-item").length,//获取子内容项个数
gap=(endAngel-startAngel)/total;//设置夹角 $(".nav-item").each(function(index){
var curAngel=startAngel+gap*index*(Math.PI/180);//js中需要把角度转换为弧度
$(this).css({
left:Math.cos(curAngel)*r+r-$(this).width()/2,
top:Math.sin(curAngel)*r+r-$(this).width()/2
})
})
}else{
$("nav").removeClass("active");
$(".btn").text("展开");
}
})
})
</script>

子元素位置计算方法:

最新文章

  1. C3p0连接池配置
  2. maven archetype生成自定义项目原型(模板)
  3. jQuery HTML
  4. Shiro标签
  5. ps命令使用 进程查看
  6. 微信第三方登陆,无需注册一键登录,获取用户信息,PHP实现方法
  7. Oracle笔记 三、function 、select
  8. bootstrap兼容IE8 解决办法
  9. arraylist与List&lt;&gt;
  10. HDU5280 Senior&amp;#39;s Array(简单DP)
  11. unity3d插件Daikon Forge GUI 中文教程-5-高级控件listbox和progress bar的使用
  12. 胖client和瘦client
  13. asp.net core系列 47 Identity 自定义用户数据
  14. Struts第一个案例搭建
  15. kubernetes系列05—kubectl应用快速入门
  16. [matlab] 10.最小覆盖
  17. OI生涯回忆录 2017.9.10~2018.11.11
  18. FFT理解
  19. PHP 批量移动文件改名
  20. TDateTimePicker中Date与Time的误导

热门文章

  1. ionic打包apkFailed to execute shell command &quot;input,keyevent,82&quot;&quot; on device: Error: adb: Command failed with exit code 137
  2. Service ANR问题
  3. n个台阶,每次都可以走一步,走两步,走三步,走到顶部一共有多少种可能
  4. jar命令:打包、查看、更新等
  5. volatility的使用
  6. APP与智能手表是如何通信的【本文摘抄自深圳尚锐科技】
  7. lintcode-127-拓扑排序
  8. Java面试题(上)
  9. vuex中获取的数据使用v-model绑定出问题
  10. CSS设计指南之ID属性