I deduce articles in a cycle: enter image description here I want each element to have a random css transform: rotate() property transform: rotate() from -2 to +2 deg, tell me how this can be implemented?

Here is the output code for the articles:

 <?php foreach ($articles as $article): ?> <div class="article"> <div class="article_title"><?php echo $article['title']; ?></div> <div class="article_img"> <img src="<?php echo $article['img1']; ?>"> </div> <a href=page_show_ads.php?id_ads=<?php echo $article["article_id"]; ?> class="article_more">Подробнее</a> </div> <?php endforeach; ?> 

    1 answer 1

    When building a html document, via php in the style attribute, it will limit from -2 to 2

     <div class='article' style='transform: rotate(<?php echo rand(-2, 2); ?>deg)'></div> 
    • But not the photo, but the block itself - id.
    • Thank you, so simple, I didn’t realize something, lokhok) - idicon
    • @idicon Please tick the correct answers - Geslot
    • @ Identon, I think this happens to many) - Mr. Black
    • @doofy Of course) - Identin