Existing random audio script need to horizontally center re-play button

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>

I don’t know JavaScript, so I don’t know if there’s some odd complexity when you’re using JS to pick the file. But any other situation, it would work to just use regular HTML/CSS styling to center that field replacement.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.