1
I want the Divs to move -50px to the left every 03 seconds. I used setInterval but it only runs the function once.
setInterval(function(){ document.querySelector('.filho').classList.add("ativado");
}, 3000);
<style>
body{
padding: 0;
margin: 0;
}
.pai{
border:solid 1px black;
display: flex;
justify-content: space-around;
}
#divs1{
padding: 100px;
background: pink;
transition: .5s;
} #divs2{
padding: 100px;
background: green;
transition: .5s;
} #divs3{
padding: 100px;
background: red;
transition: .9s;
}
.ativado{
margin-left: -50px;
}
</style>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="pai">
<div class="filho" id="divs1"></div>
<div class="filho" id="divs2"></div>
<div class="filho" id="divs3"></div>
</div>
</body>
</html>