gpt4 book ai didi

javascript - 向下滑动时旋转图像

转载 作者:太空宇宙 更新时间:2023-11-04 05:00:26 25 4
gpt4 key购买 nike

我目前正在尝试旋转此站点上的图像 http://theflouringartisans.com/目标是让顶部的箭头图像在联系人表单展开时旋转,并在表单折叠时再次旋转。这是我目前拥有的代码:

        $(document).ready(function(){

$("#contactbutton").click(function(){
if ($("#contact").is(":hidden")){
$("#contact").slideDown("slow");
$(".arrow").rotateRight(180);
}
else{
$("#contact").slideUp("slow");
$(".arrow").rotateRight(180);
}
});

});

function closeForm(){
$("#thankyou").show("slow");
setTimeout('$("#thankyou").hide();$("#contact").slideDown("slow")', 2000);
}

我还想让 div #thankyou 在提交表单 5 秒后淡出。

非常感谢任何帮助,感谢您抽出宝贵时间!

最佳答案

我从未听说过名为 rotateRight() 的 jQuery 函数,但您可以使用 css3 rotate 来做到这一点和一些 jQuery 组合。

here is css3 rotating animation example, mouse over the green box here.

jQuery:

$(document).ready(function(){
$("#contactbutton").click(function(){
if ($("#contact").is(":hidden")){
$("#contact").slideDown("slow");
$(".arrow").addClass('rotateRight');
}else{
$("#contact").slideUp("slow");
$(".arrow").removeClass('rotateRight');
}
});
});

CSS:

.rotateRight {
transform: rotate(180deg);
-ms-transform: rotate(180deg); /* IE 9 */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
-moz-transform: rotate(180deg); /* Firefox */

/* if you want to do this move with animate use transition */
transition: .5s;
-moz-transition: .5s; /* Firefox 4 */
-webkit-transition: .5s; /* Safari and Chrome */
-o-transition: .5s; /* Opera */

}

关于javascript - 向下滑动时旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11630773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com