How do I randomise colors

Hi,

you can do it via JavaScript. Here is a solution plus a a live demo. https://www.w3resource.com/javascript-exercises/javascript-math-exercise-40.php

You will need to copy the code in the front field inside tags. For instance, the Basic template front side would be the following:

{{Front}}

<script>
    function random_bg_color() {
        var x = Math.floor(Math.random() * 256);
        var y = Math.floor(Math.random() * 256);
        var z = Math.floor(Math.random() * 256);
        var bgColor = "rgb(" + x + "," + y + "," + z + ")";
     console.log(bgColor);
     document.body.style.background = bgColor;
    }

    random_bg_color();

</script>
4 Likes