We are Going to make beautiful music player with css, html and with javascript
Now here is the code of the player design it yourself
Html
<div class="player">
<div id="info" class="info">
<span class="artist">Flume</span>
<span class="name">Say it</span>
<div class="progress-bar">
<div class="bar"></div>
</div>
</div>
<div id="control-panel" class="control-panel">
<div class="album-art"></div>
<div class="controls">
<div class="prev"></div>
<div id="play" class="play"></div>
<div class="next"></div>
</div>
</div>
</div>
CSS
@import url("https://fonts.googleapis.com/css?family=Fira+Sans");
html,body {
position: relative;
min-height: 100vh;
background-color: #FFF0F5;
display: flex;
align-items: center;
justify-content: center;
font-family: "Fira Sans", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.player {
position: relative;
.info {
position: absolute;
height: 60px;
top: 0;
opacity: 0;
left: 10px;
right: 10px;
background-color: rgba(255, 255, 255, 0.5);
padding: 5px 15px 5px 110px;
border-radius: 15px;
transition: all .5s ease;
.artist,
.name {
display: block;
}
.artist {
color: #222;
font-size: 16px;
margin-bottom: 5px;
}
.name {
color: #999;
font-size: 12px;
margin-bottom: 8px;
}
.progress-bar {
background-color: #ddd;
height: 2px;
width: 100%;
position: relative;
.bar {
position:absolute;
left: 0;
top: 0;
bottom: 0;
background-color: red;
width: 10%;
transition: all .2s ease;
}
}
&.active {
top: -60px;
opacity: 1;
transition: all .5s ease;
}
}
.control-panel {
position: relative;
background-color: #fff;
border-radius: 15px;
width: 300px;
height: 80px;
z-index: 5;
box-shadow: 0px 20px 20px 5px rgba(132, 132, 132, 0.3);
.album-art {
position: absolute;
left: 20px;
top: -15px;
height: 80px;
width: 80px;
border-radius: 50%;
box-shadow: 0px 0px 20px 5px rgba(0, 0, 0, 0);
transform: scale(1);
transition: all .5s ease;
&::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 15px;
height: 15px;
background-color: #fff;
border-radius: 50%;
z-index: 5;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: 80px;
background-image: url('https://i.scdn.co/image/9dcbd30dbe0c621cbaeae427cf80eff9877b4fcd');
}
}
&.active .album-art {
box-shadow: 0px 0px 20px 5px rgba(0, 0, 0, 0.2);
transform: scale(1.2);
transition: all .5s ease;
}
&.active .album-art::before {
animation: rotation 3s infinite linear;
-webkit-animation: rotation 3s infinite linear;
animation-fill-mode: forwards;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.controls {
display: flex;
justify-content: flex-end;
height: 80px;
padding: 0 15px;
.prev,
.play,
.next {
width: 55px;
height: auto;
border-radius: 10px;
background-position: center center;
background-repeat: no-repeat;
background-size: 20px;
margin: 5px 0;
background-color: #fff;
cursor: pointer;
transition: background-color .3s ease;
-webkit-transition: background-color .3s ease;
}
.prev:hover,
.play:hover,
.next:hover {
background-color: #eee;
transition: background-color .3s ease;
-webkit-transition: background-color .3s ease;
}
.prev {
background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTguMS4xLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDI1MC40ODggMjUwLjQ4OCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMjUwLjQ4OCAyNTAuNDg4OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgd2lkd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.play = this.play.bind(this);
this.playBtn = document.getElementById('play');
this.playBtn.addEventListener('click', this.play);
this.controlPanel = document.getElementById('control-panel');
this.infoBar = document.getElementById('info');
}
play() {
let controlPanelObj = this.controlPanel,
infoBarObj = this.infoBar
Array.from(controlPanelObj.classList).find(function(element){
return element !== "active" ? controlPanelObj.classList.add('active') : controlPanelObj.classList.remove('active');
});
Array.from(infoBarObj.classList).find(function(element){
return element !== "active" ? infoBarObj.classList.add('active') : infoBarObj.classList.remove('active');
});
}
}
const newMusicplayer = new musicPlayer();
And Your Music Player Look like this
All Credited by Shayan UI/ UX DESIGN INSPIRATION on Instagram: “Made with InVision Studio — Music Player by Charles Patterson @charlespats