I’m using the script below to play a random sound file. It works great but was wondering how I can horizontally center the replay button.
<div class="snd" hidden>{{Sound1}}</div>
<div class="snd" hidden>{{Sound2}}</div>
<div class="snd" hidden>{{Sound3}}</div>
<script>
{
const fields = document.querySelectorAll(".snd");
const soundButtons = document.querySelectorAll(".snd .replay-button");
function randomInt(max) {
return Math.floor(Math.random() * max);
}
rand = randomInt(fields.length)
fields[rand].hidden = false;
soundButtons[rand].click();
}
</script>