Search code examples
htmlaudiocenter

How can i center a Audio Player?


how can i center the audio player?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        #playlist{
            list-style: none;
        }
        #playlist li a{
            color:white;
            text-decoration: none;
        }
        #playlist .current-song a{
            color:blue;
        }
        body {background-color: black;}
        h1 {color: white;}
        p {color: white;}
    </style>
    <link rel="shortcut icon" type="image/ico" href="/img/favicon.ico">
</head>
<body>
    <audio src="" controls autoplay id="audioPlayer">
        Sorry, your Browser doesn't Support HTML5!
    </audio>
    <ul id="playlist">
        <li class="current-song"><a href="/music/song1.mp3"></a></li>
        <li><a href="/music/song2.mp3"></a></li>
    </ul>
    <!-- <p>Back to <a href="https://URL/">URL</a></p> -->
    <script src="https://code.jquery.com/tt.js"></script>
    <script src="audioPlayer.js"></script>
    <script>
        audioPlayer();
    </script>
</body>
</html>

This is what i have so far: https://prnt.sc/r4o3nh And this is what i want: https://prnt.sc/r4o3en

What i tried: style="display: block; margin: 0 auto; style="position:absolute;top:0;left:0;width:100%;height:100%;" width="1400" height="900"


Solution

  • Try this:

    audio#audioPlayer {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      margin: auto;
    }