Looking to animate a line infinitely on my website, here is the code snippet:
<body>
<div class="line_1"></div>
<div class="line_2"></div>
<div class="line_3"></div>
</body>
The CSS applied for styling the lines:
body {
padding:50px;
}
.line_1 {
position:relative;
width:50px;
height:5px;
opacity:0.3;
background-color:#ef4646;
transform:rotate(-45deg);
transform-origin:left;
top: -10px;
left: 10px;
}
.line_2 {
position:relative;
width:50px;
height:5px;
opacity:0.3;
background-color:#86b4fc;
transform:rotate(45deg);
transform-origin:left;
top: 10px;
left: 10px;
}
.line_3 {
position:relative;
top:60px;
left: -40px;
width:50px;
height:5px;
opacity:0.3;
background-color:#f7e551;
transform:rotate(-45deg);
transform-origin:right;
The script used for animation:
<script type="text/javascript">
$(document).ready(function () {
$('.line_1').animate({ opacity:"1",left:"0px",top:"0px" });
setInterval(function () { $('.line_2').animate({ opacity: "1", left: "0px", top: "0px" }); },400);
setInterval(function () { $('.line_3').animate({ opacity: "1", left: "-10px", top: "30px" }); }, 600);
});
</script>
The current issue is that the animation only plays once when the page loads. Any suggestions on how to make it repeat continuously would be greatly appreciated. Thank you!