html 5 音频标签宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5635365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
html 5 audio tag width
提问by user704063
I was wondering if it's possible to set the width of the audio tag. It is not a supported feature by default, so "hacks" will be happily accepted.
I already tried putting them in small div's and tables, but that doesn't look very smooth... As far as I can see, I'm the only one bothering about it, but I really appreciate some help
我想知道是否可以设置音频标签的宽度。默认情况下它不是受支持的功能,因此“hacks”将被愉快地接受。
我已经尝试将它们放在小 div 和表格中,但这看起来不是很顺利......据我所知,我是唯一一个为此烦恼的人,但我真的很感激一些帮助
There is no need for cross-platform/browser support; I'm happy as long as FireFox (3.6 ++) supports it.
不需要跨平台/浏览器支持;只要 FireFox (3.6 ++) 支持它,我就很高兴。
Quick example as to what I'll be using:
关于我将使用什么的快速示例:
<audio preload="auto" id="id12" controls="controls" onended="func12();" src="http://192.168.1.68/mymusic.wav"></audio>
回答by robertc
Set it the same way you'd set the width of any other HTML element, with CSS:
使用 CSS 以与设置任何其他 HTML 元素的宽度相同的方式设置它:
audio { width: 200px; }
Note that audio
is an inline element by default in Firefox, so you might also want to set it to display: block
. Here's an example.
请注意,这audio
是 Firefox 中默认的内联元素,因此您可能还想将其设置为display: block
. 这是一个例子。
回答by rogerdpack
For those looking for an inline example, here is one:
对于那些寻找内联示例的人,这里有一个:
<audio controls style="width: 200px;">
<source src="http://somewhere.mp3" type="audio/mpeg">
</audio>
It doesn't seem to respect a "height" setting, at least not awesomely. But you can always "customize" the controls but creating your own controls (instead of using the built-in ones) or using somebody's widget that similarly creates its own :)
它似乎不尊重“高度”设置,至少不是非常。但是您始终可以“自定义”控件,但可以创建自己的控件(而不是使用内置控件)或使用类似创建自己的控件的某人的小部件:)
回答by Calvin
You also can set the width of a audio tag by JavaScript:
您还可以通过 JavaScript 设置音频标签的宽度:
audio = document.getElementById('audio-id');
audio.style.width = '200px';
回答by XMMR12
You can use html and be a boss with simple things :
您可以使用 html 并通过简单的事情成为老板:
<embed src="music.mp3" width="3000" height="200" controls>
<embed src="music.mp3" width="3000" height="200" controls>