HTML - 将音频对象放在右上角

时间:2016-04-07 08:40:16

标签: html css

我需要将<audio>放在右上角。怎么做? 我尝试使用<object>但是我在音频播放器周围出现了黑条。

&#13;
&#13;
<!DOCTYPE html>
<head>
  <style>
  </style>
</head>
<center>
  <body style="background-color: brown">
    <h1 style="color:white; font-size:80px">Hello</h1>
    <p style="font-size:50px">I like <span style="color:green">turtlez</p>
      <audio controls>
        <source src="hello.mp3" align="right" type="audio/mpeg">
      </audio>
  </body>
</center>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

将音频元素放入容器中,然后对齐容器。

E.g。

<div class="container">
<audio controls>
  <source src="hello.mp3" align="right" type="audio/mpeg">
</audio>
</div>

.container {
max-width:200px;
position:absolute;
top:0;
right:0;
}

答案 1 :(得分:0)

尝试使用此代码:

&#13;
&#13;
audio {
  float: right;
  margin-top:0;
}
&#13;
<audio controls src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga">
  Your user agent does not support the HTML5 Audio element.
</audio>
&#13;
&#13;
&#13;

确保包含您的src文件。 希望它有效。