bootstrap 模态内的音频标签工作正常,但下载按钮位置超出模态
Audio tag inside the bootstrap modal working fine but the download button position is out of modal
我正在尝试在模式中添加音频标签,但下载按钮不在模式中,这已在 chrome 上测试。
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Open modal with Audio
</button>
<div class="modal" id="exampleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<audio controls controlsList="download" style="width:100%">
<source src="https://www.w3schools.com/TagS/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我知道我们可以隐藏下载按钮,但万一我们想保留它,不确定是否有解决方案。这是 pen
上的代码
不幸的是,这似乎是使用 <audio>
标签以及偶尔使用 <video>
或 <iframe>
的常见问题。有一些方法可以最小化修改样式但不能解决问题。
我能想到的是通过标签创建您自己的下载 link。禁用原始下载 link 并在 <audio>
标签样式中创建您自己的下载 link 和 "fit"。新的 link 会将整个 <audio>
标签打开到一个新页面中,然后在必要时使用下载 link。
您可以在您的代码笔中试用下面的代码。 Whosebug 似乎阻止了沙箱中的弹出窗口。
尽管如此,我认为这很复杂,但您可以将其作为一个想法。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Open modal with Audio
</button>
<div class="modal" id="exampleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body d-flex">
<div class="w-100 d-flex" style="background-color: #f1f3f4; border-radius: 2rem">
<audio controls controlsList="nodownload" style="width:100%; position:fix">
<source src="https://www.w3schools.com/TagS/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<a class="text-center" target="_blank" style="line-height:54px; margin-right:1rem" href="https://www.w3schools.com/TagS/horse.ogg">Icon
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/ogg">
</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
应用变换:none; 属性 在模态对话框上 class。
我正在尝试在模式中添加音频标签,但下载按钮不在模式中,这已在 chrome 上测试。
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Open modal with Audio
</button>
<div class="modal" id="exampleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<audio controls controlsList="download" style="width:100%">
<source src="https://www.w3schools.com/TagS/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我知道我们可以隐藏下载按钮,但万一我们想保留它,不确定是否有解决方案。这是 pen
上的代码不幸的是,这似乎是使用 <audio>
标签以及偶尔使用 <video>
或 <iframe>
的常见问题。有一些方法可以最小化修改样式但不能解决问题。
我能想到的是通过标签创建您自己的下载 link。禁用原始下载 link 并在 <audio>
标签样式中创建您自己的下载 link 和 "fit"。新的 link 会将整个 <audio>
标签打开到一个新页面中,然后在必要时使用下载 link。
您可以在您的代码笔中试用下面的代码。 Whosebug 似乎阻止了沙箱中的弹出窗口。
尽管如此,我认为这很复杂,但您可以将其作为一个想法。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Open modal with Audio
</button>
<div class="modal" id="exampleModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body d-flex">
<div class="w-100 d-flex" style="background-color: #f1f3f4; border-radius: 2rem">
<audio controls controlsList="nodownload" style="width:100%; position:fix">
<source src="https://www.w3schools.com/TagS/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<a class="text-center" target="_blank" style="line-height:54px; margin-right:1rem" href="https://www.w3schools.com/TagS/horse.ogg">Icon
<source src="https://www.w3schools.com/TagS/horse.mp3" type="audio/ogg">
</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
应用变换:none; 属性 在模态对话框上 class。