Outline html5 audio element

房东的猫 提交于 2021-01-28 09:50:38

问题


I have disabled the browser outline from showing because I'd like to implement my own that's always there - not just when the audio element is clicked.

.audio-player {
  display: block;
  width: 50%;
  margin-left: auto;
  margin-right: auto;
}

@media only screen and (max-width: 500px) {
  .audio-player {
    display: block;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
}

.audio-center {
  margin-left: auto;
  margin-right: auto;
  display: block;
  box-shadow: 0px 0.25px 5px #000000;
}

audio {
  outline: none;
  display: block;
  background-color: transparent !important;
  -webkit-tap-highlight-color: transparent;
}
<div class="audio-player">
  <div>
    <audio class="audio-center" controls controlsList="nodownload">
            <source src="audio.mp3" type="audio/mpeg">
            Your browser does not support the audio element.
         </audio>
  </div>
</div>

I could set the border-radius of the outline to 25px and it'd look fine in Chrome.

.audio-player {
  display: block;
  width: 50%;
  margin-left: auto;
  margin-right: auto;
}

@media only screen and (max-width: 500px) {
  .audio-player {
    display: block;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
}

.audio-center {
  margin-left: auto;
  margin-right: auto;
  display: block;
  box-shadow: 0px 0.25px 5px #000000;
  border-radius: 25px;
}

audio {
  outline: none;
  display: block;
  background-color: transparent !important;
  -webkit-tap-highlight-color: transparent;
}
<div class="audio-player">
  <div>
    <audio class="audio-center" controls controlsList="nodownload">
            <source src="audio.mp3" type="audio/mpeg">
            Your browser does not support the audio element.
         </audio>
  </div>
</div>

Surely though there's a way to outline the actual audio element that outlines the browser's native styling for the audio element?

UPDATE The audio element should be outlined. Setting a border radius works for the edge audio player but not the chrome one so there needs to be a way to add a border that fits and outlines the audio element on all browsers.

来源:https://stackoverflow.com/questions/62156596/outline-html5-audio-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!