gpt4 book ai didi

javascript - jQuery 动画,从一侧传入,传递和对象,然后从另一侧传出。直线

转载 作者:行者123 更新时间:2023-11-28 06:41:59 27 4
gpt4 key购买 nike

我在学习 javaScript 和 jQuery 的第一周,我正在尝试制作一些动画。

基本上我想要做的就是让这些箭头从屏幕开始,从一侧进入,通过 throw 目标,然后离开屏幕的另一侧。

理想情况下,它会发射一个,当它大约穿过屏幕的 3/4 时,下一个会发射所有 8 支箭。

HTML

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="jQuery.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src="jQuery.js" type"text/javaScript"></script>
</head>
<body>
<button class="clickme">
Click Me
</button>
<span class="uparrow">
</span>
<span class="uparrow2">
</span>
<span class="downarrow">
</span>
<span class="downarrow2">
</span>
<span class="leftarrow">
</span>
<span class="leftarrow2">
</span>
<span class="rightarrow">
</span>
<span class="rightarrow2">
</span>
<div class="target">
<img src="http://simpleicon.com/wp-content/uploads/target1.svg" alt="">
</div>
<div class="target2">
<img src="http://simpleicon.com/wp-content/uploads/target1.svg" alt="">
</div>
</body>
</html>

CSS ----------所有箭头当前都放置在目标位置并隐藏。

.uparrow {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
top: 23%;
left: 23%;
position: absolute;
display: none;
}
.uparrow2 {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
top: 63%;
left: 63%;
position: absolute;
display: none;
}
.downarrow {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 100px solid red;
top: 23%;
left: 23%;
position: absolute;
display: none;
}
.downarrow2 {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 100px solid red;
top: 63%;
left: 63%;
position: absolute;
display: none;
}
.left arrow {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-right: 100px solid red;
border-bottom: 50px solid transparent;
top: 65%;
left: 63%;
position: absolute;
display: none;
}
.leftarrow2 {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-right: 100px solid red;
border-bottom: 50px solid transparent;
top: 25%;
left: 23%;
position: absolute;
display: none;
}
.rightarrow {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-left: 100px solid red;
border-bottom: 50px solid transparent;
top: 25%;
left: 23%;
position: absolute;
display: none;
}
.rightarrow2 {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-left: 100px solid red;
border-bottom: 50px solid transparent;
top: 65%;
left: 63%;
position: absolute;
display: none;
}
.target {
width: 200px;
height: 200px;
margin: 0 auto;
position: absolute;
top: 60%;
left: 60%;
}
.target2 {
width: 200px;
height: 200px;
position: absolute;
top: 20%;
left: 20%;
}

img {
width: 100%;
height: 100%;
}

jQuery ---- 我已经尝试了一些东西,但我很茫然,基本上希望它在单击按钮时触发。我很困惑最初是我的 CSS 位置还是其他原因。

$(document).ready( function(){

$(".clickme").click( function() {

//end click function
});
//end document
});

我该怎么做,只是直线,通过 throw 目标。

最佳答案

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type"text/javaScript"></script>
<style type="text/css">
.uparrow { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red; top: 23%; left: 23%; position: absolute; display: none; } .uparrow2 { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red; top: 63%; left: 63%; position: absolute; display: none; } .downarrow { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 100px solid red; top: 23%; left: 23%; position: absolute; display: none; } .downarrow2 { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 100px solid red; top: 63%; left: 63%; position: absolute; display: none; } .left arrow { width: 0; height: 0; border-top: 50px solid transparent; border-right: 100px solid red; border-bottom: 50px solid transparent; top: 65%; left: 63%; position: absolute; display: none; } .leftarrow2 { width: 0; height: 0; border-top: 50px solid transparent; border-right: 100px solid red; border-bottom: 50px solid transparent; top: 25%; left: 23%; position: absolute; display: none; } .rightarrow { width: 0; height: 0; border-top: 50px solid transparent; border-left: 100px solid red; border-bottom: 50px solid transparent; top: 25%; left: 23%; position: absolute; display: none; } .rightarrow2 { width: 0; height: 0; border-top: 50px solid transparent; border-left: 100px solid red; border-bottom: 50px solid transparent; top: 65%; left: 63%; position: absolute; display: none; } .target { width: 200px; height: 200px; margin: 0 auto; position: absolute; top: 60%; left: 60%; } .target2 { width: 200px; height: 200px; position: absolute; top: 20%; left: 20%; }
</style>
</head>
<body>
<button class="clickme">
Click Me
</button>
<span class="uparrow">
</span>
<span class="uparrow2">
</span>
<span class="downarrow">
</span>
<span class="downarrow2">
</span>
<span class="leftarrow">
</span>
<span class="leftarrow2">
</span>
<span class="rightarrow">
</span>
<span class="rightarrow2">
</span>
<div class="target">
me
</div>
<div class="target2">
me
</div>
<script type="text/JavaScript">
$(document).ready( function(){

$(".clickme").click( function() {

//end click function
});
//end document
});
</script>
</body>
</html>

关于javascript - jQuery 动画,从一侧传入,传递和对象,然后从另一侧传出。直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34234919/

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