So I'm trying to make each individual post (.card) on a WordPress site stagger, some more to the left, some to the right, and for this to be a random amount and to change on refreshing the page.
This is where I am at with the JavaScript code to try and do this:
//random position
$(document).ready(function () {
$('.card').each(function () {
$('.card').css({
'left': (Math.random() * 900) + 50
})
});
});
I don't think I am using the 'each' method correctly? It randomly places them left / right, but it applies the same distance to all posts, instead of each one being at a different distance.
Where am I going wrong here?
Aucun commentaire:
Enregistrer un commentaire