Skip to content

Instantly share code, notes, and snippets.

@ldavidsp
Created May 13, 2019 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldavidsp/68d323e734c0d0fbec126c972fa75e47 to your computer and use it in GitHub Desktop.
Save ldavidsp/68d323e734c0d0fbec126c972fa75e47 to your computer and use it in GitHub Desktop.
Styling <Audio Tag>
<article>
<div class="cont">
<h3>100: Big Ones</h3>
<time>JULY 26, 2016</time>
</div>
<audio class="audio" controls="controls">
<source type="audio/mpeg" src="http://media.blubrry.com/codepen_radio/p/codepen-podcast.s3.amazonaws.com/100.mp3?_=1">
</audio>
</article>
$('audio').mediaelementplayer({
features: ['playpause','progress','current','tracks','fullscreen']
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.22.0/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.22.0/mediaelement-and-player.min.js"></script>
@import 'https://fonts.googleapis.com/css?family=Lato';
* {
outline: none;
}
body {
background: #343436;
font-family: 'Lato';
}
/*👇 for preload play/pause svg 😎*/
body:after {
position: absolute;
width: 0;
height: 0;
overflow: hidden;
z-index: -1;
content: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/163884/play.svg)
url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/163884/pause.svg);
}
article{
position: absolute;
width: 50%;
height: 300px;
top: 40px;
left: 0;
bottom: 0;
right: 0;
margin: auto;
text-align: center;
padding: 50px 5%;
box-sizing: border-box;
box-shadow: 0 0 21px 0px rgba(0,0,0,0.3);
border-radius: 10px;
}
.cont{
margin-bottom: 28px;
}
.cont h3{
font-family: 'Lato';
font-size: 50px;
margin: 0 0 10px 0;
color: #ccc;
}
.cont time{
font-family: 'Lato';
font-size: 12px;
color: #999;
}
/*
*style audio tag
*/
.mejs-container {
background: #000;
font-family: Helvetica, Arial;
text-align: left;
vertical-align: top;
text-indent: 0;
width: 100% !important;
height: 50px !important;
border-radius: 5px;
}
.mejs-container .mejs-controls {
height: 100%;
background: transparent;
display: flex;
}
.mejs-controls .mejs-time-rail span,
.mejs-controls .mejs-time-rail a {
display: block;
width: 180px;
height: 100%;
border-radius: 0px;
cursor: pointer;
}
.mejs-controls div.mejs-time-rail {
padding-top: initial;
height: 100%;
}
.mejs-controls .mejs-time-rail .mejs-time-total {
margin: 0
}
.mejs-container .mejs-controls .mejs-time {
color: #fff;
display: block;
height: 27px;
width: auto;
padding: 0;
line-height: 25px;
overflow: hidden;
text-align: center;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
.mejs-container .mejs-controls .mejs-time {
position: absolute;
color: rgba(256, 256, 256, 0.3);
right: 10px;
bottom: 0;
top: 0;
margin: auto;
font-family: 'Lato';
font-size: 32px;
pointer-events: none;
}
.mejs-controls .mejs-time-rail .mejs-time-float-corner {
display: none;
}
.mejs-controls .mejs-time-rail .mejs-time-float {
position: absolute;
background: #000;
width: 46px;
height: 20px;
border: none;
top: -25px;
margin-left: -18px;
text-align: center;
color: #fff;
border-radius: 3px;
}
.mejs-controls .mejs-time-rail .mejs-time-float-current {
margin: 0;
margin-top: 4px;
width: 100%;
display: block;
text-align: center;
left: 0;
}
.mejs-container .mejs-controls div {
height: 100%;
width: 50px;
position: relative;
}
.mejs-controls .mejs-button button {
margin: 0;
padding: 0;
position: relative;
height: 100%;
width: 100%;
border: 0 !important;
background: transparent;
outline: none;
}
.mejs-controls .mejs-play:after {
position: absolute;
content: "";
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/163884/play.svg) no-repeat;
width: 17px;
height: 22px;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
transition: all 100ms linear;
pointer-events: none;
}
.mejs-controls .mejs-pause:after {
position: absolute;
content: "";
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/163884/pause.svg) no-repeat;
width: 13px;
height: 22px;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
transition: all 100ms linear;
pointer-events: none;
}
.mejs-controls .mejs-time-rail .mejs-time-total {
background: #292929;
}
.mejs-controls .mejs-time-rail .mejs-time-loaded {
background: #3c3838;
background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.75, rgba(255, 255, 255, .2)), color-stop(.75, transparent), to(transparent));
background-image: -moz-linear-gradient( -45deg, rgba(255, 255, 255, .2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%, transparent 75%, transparent);
background-size: 50px 50px;
animation: move 3s linear infinite;
opacity: 0.1;
}
.mejs-controls .mejs-time-rail .mejs-time-current {
background: linear-gradient(to right, #03A9F4, #ff00ff);
}
.mejs-controls .mejs-button button:focus {
outline: none;
}
@-webkit-keyframes move {
0% {
background-position: 0 0;
}
100% {
background-position: 50px 50px;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.22.0/mediaelementplayer.min.css" rel="stylesheet" />

Styling

Styling Audio Tag for Podcast

Although late I wanted to celebrate in my way the hundredth Codepen podcast, stylinig the audio tag with mediaElement plugin

A Pen by Tommaso Poletti on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment