jq 图片滑到顶部时翻转90度离开,划进来时也是翻转90度进来,代码该怎么写啊

jq 图片滑到顶部时翻转90度离开,划进来时也是翻转90度进来,代码该怎么写啊,第1张

没看明白您的具体意图,DIV到顶部时固定什么意思 拉动滚动条可以使用windowscroll()来触发函数。 自定义一个函数,判断$(document)scrollTop()值与div的top值,从而进行对应的 *** 作。

CSS20实现不了,CSS30有个rotate属性,写法:xxx:hover{-webkit-transform:rotate(360deg)},但是不兼容IE10以下的浏览器
还有一种办法,再做一张旋转的,鼠标hover的时候变成那张旋转的就好了!
JS可能也可以实现,不过应该会很麻烦

如下图所示:

解决思路:
注意:display:none和 visibility: hidden区别=>
display:none的div处于消失的状态
visbility:hidden的div处于占用了空间但是被隐藏的状态(具有高和宽,占据空间位置)
1页面默认向下箭头处于显示二级模块(默认展开给游客看起来这个箭头是可以展开的状态,让游客清晰明了的知道)
css实现效果(display:block)需要把二级模块的样式写好,然后再加上一个display=block的属性即可。
2页面默认向左箭头处于隐藏二级模块(默认关闭状态)
css实现效果(display:none)需要把二级模块的样式写好,然后再加上一个display=block的属性即可。
3js实现特效的展开与收缩的状态
思路:
1首先如果处于当前页面,页面就处于展开的状态也就是说页面处于显示的状态,其他模块处于关闭状态。(display:block)
这是一次if判断
2从游客的需求上来说,游客点击向下箭头,然后二级模块就会被收缩出现向左的箭头。(display:none)
这又是一次if判断
3如果是后台需要动态获取导航栏模块的数量需要后台给个标志性的数据,然后拿到后台的这个数据去做判断第一层判断。
4实践。

rotate是jQuery旋转rotate插件,支持Internet Explorer 60+ 、Firefox 20 、Safari 3 、Opera 9 、Google Chrome,高级浏览器下使用Transform,低版本ie使用VML实现。 rotate(angle)angle参数:[Number] – 默认为 0
<pre t="code" l="java">根据给定的角度旋转例如:
$(“#img”)rotate(45);或 $(‘#img’)rotate({angle:45})rotate(parameters)parameters参数:[Object] 包含旋转参数的对象。支持的属性:1angle属性:[Number] – default 0 – 旋转的角度数,并且立即执行<pre t="code" l="js">例如:1$(“#img”)rotate({angle:45});2bind属性:[Object] 对象,包含绑定到一个旋转对象的事件。事件内部的$(this)指向旋转对象-这样可以在内部链式调用- $(this)rotate(…)。<pre t="code" l="js">例如 (click on arrow):
$(“#img”)rotate({bind:{
click: function(){
$(this)rotate({
angle: 0,
animateTo:180
})
}
}
});3animateTo属性:[Number] – default 0 – 从当前角度值动画旋转到给定的角度值 (或给定的角度参数)
4duration属性:[Number] – 指定使用animateTo的动画执行持续时间<pre t="code" l="js">例如 (click on arrow):
$(“#img”)rotate({bind:{
click: function(){
$(this)rotate({
duration:6000,
angle: 0,
animateTo:100
})
}
}
});5 step属性:[Function] – 每个动画步骤中执行的回调函数,当前角度值作为该函数的第一个参数
6 easing属性:[Function] – 默认 (see below) 默认:function (x, t, b, c, d) { return -c ((t=t/d-1)ttt - 1) + b; }Where:t: current time,b: begInnIng value,c: change In value,d: duration,x: unused没有渐变:No easing (linear easing):function(x, t, b, c, d) { return (t/d)c ; } <pre t="code" l="js">示例1:没有效果,一直转
$("#scImg")rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){
return (t/d)c ;
}
}); <pre t="code" l="js">示例2: 默认的效果
$("#scImg")rotate({
angle:0,
animateTo:360,
callback: rotation,
easing: function (x,t,b,c,d){
return -c((t=t/d-1)ttt-1)+b ;
}
});<pre t="code" l="js">示例3:
$(“#img”)rotate({bind:{
click: function(){
$(this)rotate({
angle: 0,
animateTo:180,
easing: $easingeaseInOutElastic
})
}
}
});
7callback属性:[Function] 动画完成时执行的回调函数例如<pre t="code" l="js">$(“#img”)rotate({bind:{
click: function(){
$(this)rotate({
angle: 0,
animateTo:180,
callback: function(){ alert(1) }
})
}
}
});8 getRotateAngle这个函数只是简单地返回旋转对象当前的角度。<pre t="code" l="js">例如:
$(“#img”)rotate({
angle: 45,
bind: {
click : function(){
alert($(this)getRotateAngle());
}
}
});9stopRotate这个函数只是简单地停止正在进行的旋转动画。例如:<pre t="code" l="js">$(“#img”)rotate({
bind: {
click: function(){
$(“#img”)rotate({
angle: 0,
animateTo: 180,
duration: 6000
});
setTimeout(function(){
$(“#img”)stopRotate();
}, 1000);
}
}
});


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/13364140.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-22
下一篇 2023-07-22

发表评论

登录后才能评论

评论列表(0条)

保存