GitHub网址
参考样式注解
// :root {
// --white: #fff;
// --active-color: #00aeb0;
// }
* {
box-sizing: border-box;
}
// 控制整个页面样式
// html {
// font-family: Arial, Helvetica, sans-serif;
// height: 100%;
// background: var(--active-color);
// transition: background 0.4s ease;
// }
// 控制按钮的样式
button {
background: none;
border: none;
cursor: pointer;
}
// 控制进度条的样式
input[type='range'] {
height: 5px;
-webkit-appearance: none;
width: 100%;
margin-bottom: 10px;
border-radius: 8px;
background: #3b7677;
transition: background 0.2s ease;
cursor: pointer;
}
// 存放音乐的盒子大小样式
.audio-player {
max-width: 100%;
padding: 24px;
border-radius: 20px;
box-shadow: 0 28px 28px rgba(0, 0, 0, 0.2);
margin: auto;
color: var(--white);
font-family: Arial, Helvetica, sans-serif;
height: 100%;
background: var(--active-color);
transition: background 0.4s ease;
--white: #fff;
--active-color: #00aeb0;
}
// 控制音乐图片
.artwork {
border-radius: 10rem;
display: block;
margin: auto;
height: 3rem;
width: 3rem;
animation: rotation 2s infinite linear;
}
// 控制文本及按钮的位置
.track-info {
text-align: center;
z-index: 1;
// position: relative;
}
// 控制图片底下的文本
// .title {
// font-weight: 50;
// font-size: 1rem;
// margin-bottom: 1rem;
// }
.artist {
font-weight: 50;
margin-top: 0;
}
// 控制按钮的位置
.audio-controls {
display: flex;
justify-content: space-between;
width: 75%;
margin: 0 auto 1rem;
}
// 控制左右按钮的大小
.audio-controls .prev svg,
.audio-controls .next svg {
width: 1.5rem;
height: 1.5rem;
}
// 控制中间的播放按钮
.audio-controls .play svg,
.audio-controls .pause svg {
height: 2rem;
width: 2rem;
}
// 控制按钮的颜色
.audio-controls path {
fill: var(--white);
}
// 控制全局样式跟着一起改变
// .color-backdrop {
// background: linear-gradient(45deg, var(--active-color) 20%, transparent 100%)
// no-repeat;
// position: absolute;
// top: 0;
// left: 0;
// right: 0;
// bottom: 0;
// z-index: -1;
// }
// 动画效果
// .color-backdrop.playing {
// animation: colorChange 20s alternate infinite;
// }
// @keyframes colorChange {
// from {
// filter: hue-rotate(0deg);
// }
// to {
// filter: hue-rotate(360deg);
// }
// }
// 实现动画持续旋转效果
@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}