我想让 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 - 如何让html5音频播放器响应式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65616144/