<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
</head>
<style>
*{
padding: 0;
margin: 0;
}
html,body{
height: 100%;
overflow: hidden;
}
#warp{
height: 64px;
width: 64px;
position: fixed;
right: 15px;
bottom: 15px;
}
#warp > .inner{
height: 100%;
}
#warp > .inner > img{
position: absolute;
left:0;
top:0;
border-radius: 50%;
/* transition: 2s; */
}
#warp > .home{
position: absolute;
z-index: 1;
height: 100%;
width: 100%;
left:0;
top:0;
background: url("img/bfw.png") no-repeat;
border-radius: 50%;
transition: 1s;
}
</style>
<body>
<div id="warp">
<div class="inner">
<img src="img/hfw.png" alt="">
<img src="img/bmrc.png" alt="">
<img src="img/hyjy.png" alt="">
<img src="img/ldrc.png" alt="">
<img src="img/qb.png" alt="">
</div>
<div class="home"></div>
</div>
</body>
<script type="text/javascript">
// 1.在元素首次渲染还没有完成的情况下,是不会触发过渡的
// 2.在绝大部分变换样式切换时,如果变换函数位置、 个数不相同也不会触发过渡
// 勾股定理、三角函数、角度与弧度的转换
window.onload=function(){
var homeEle=document.querySelector(".home")
var imgs=document.querySelectorAll("#warp > .inner > img")
var flag=true,c=140
function fn(){
this.style.transition="0.3s "
this.style.transform="rotate(-720deg) scale(1) "
this.style.opacity="1"
this.removeEventListener("transitionend",fn)
}
for (var i = 0; i < imgs.length; i++) {
imgs[i].onclick=function(){
this.style.transition="0.5s "
this.style.transform="rotate(-720deg) scale(2)"
this.style.opacity="0.1"
this.addEventListener("transitionend",fn)
}
}
homeEle.onclick=function(){
if(flag){
this.style.transform="rotate(-720deg)"
for(i=0;i<imgs.length;i++){
imgs[i].style.transition="1s "+(i*.15)+"s"
imgs[i].style.transform="rotate(-720deg) scale(1)"
imgs[i].style.left=-getPoinet(c,90*i/(imgs.length-1)).left+"px";
imgs[i].style.top=-getPoinet(c,90*i/(imgs.length-1)).top+"px";
}
}else{
this.style.transform="rotate(0deg)"
for(i=0;i<imgs.length;i++){
imgs[i].style.transition="1s "+((imgs.length-1-i)*0.15)+"s" //动画时间,延时
imgs[i].style.transform="rotate(0deg) scale(1)" //旋转
imgs[i].style.left="0px";
imgs[i].style.top="0px";
}
}
flag=!flag
}
// 已知第三边和一个角
function getPoinet(c,deg){
var x=Math.round(c*Math.sin(deg*Math.PI/180))
var y=Math.round(c*Math.cos(deg*Math.PI/180))
return {left:x,top:y};
}
}
</script>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
css+javascript 实现扇形导航动画效果
共7个文件
png:6个
html:1个
需积分: 5 2 下载量 82 浏览量
2023-06-08
16:43:25
上传
评论
收藏 18KB ZIP 举报
温馨提示
css+javascript 实现扇形导航,有动画效果,从找到到收回,可以直接下载使用
资源推荐
资源详情
资源评论
收起资源包目录
扇形导航.zip (7个子文件)
扇形导航
扇形导航.html 3KB
img
bmrc.png 1KB
qb.png 2KB
hfw.png 8KB
ldrc.png 2KB
bfw.png 1KB
hyjy.png 1KB
共 7 条
- 1
资源评论
飞鱼点点
- 粉丝: 11
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功