如何让 html5 音频播放器响应?
How to make html5 audio player responsive?
我想让 html 5 个音频播放器响应:
<audio controls class="audio-file" src="/path/to/music.mp3">
Sorry your browser belongs to stone age
</audio>
我试过一些粗的像
audio {
display: block;
}
但宽度没有任何变化,随着屏幕缩小,它超出了可见区域。我想知道解决此问题的最佳方法是什么?
通过添加对象匹配来试试这个 css 属性
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
<style>
body {
display: block;
margin: 8px;
}
audio{
max-height: 100%;
max-width: 100%;
margin: auto;
object-fit: contain;
}
</style>
</head>
<body>
<audio controls="" autoplay="" name="media">
<source src="path/to/music.mp3" type="audio/mpeg">
</audio>
</body>
</html>
我想让 html 5 个音频播放器响应:
<audio controls class="audio-file" src="/path/to/music.mp3">
Sorry your browser belongs to stone age
</audio>
我试过一些粗的像
audio {
display: block;
}
但宽度没有任何变化,随着屏幕缩小,它超出了可见区域。我想知道解决此问题的最佳方法是什么?
通过添加对象匹配来试试这个 css 属性
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
<style>
body {
display: block;
margin: 8px;
}
audio{
max-height: 100%;
max-width: 100%;
margin: auto;
object-fit: contain;
}
</style>
</head>
<body>
<audio controls="" autoplay="" name="media">
<source src="path/to/music.mp3" type="audio/mpeg">
</audio>
</body>
</html>