布局实现
1. 头部
<header>
<div class="logo">
<img src="img/player_logo.png" alt="">
</div>
<ul>
<li><a href="#">登录</a></li>
<li><a href="#">设置</a></li>
</ul>
</header>
2.主体部分
比较简单,主要分为左侧歌曲列表和右侧歌曲信息
<main>
<div class="music">
<ul class="music_nav">
<li><span></span>收藏</li>
<li><span></span>添加到</li>
<li><span></span>下载</li>
<li><span></span>删除</li>
<li><span></span>清空列表</li>
</ul>
<div class="music_list">
<div class="musics">
<li class="list_check"><i></i></li>
<li class="list_num"></li>
<li class="list_song">歌曲</li>
<li class="list_name">歌手</li>
<li class="list_time">时长</li>
</div>
</div>
</div>
<div class="info">
<div class="info_img">
<img src="img/傅如乔.png" alt="">
</div>
<div class="info_words">
<a href="#">歌曲名称:</a>
<span class="info_name"></span><br>
<a href="#">歌手名:</a>
<span class="info_singer"></span><br>
<a href="#">专辑信息:</a>
<span class="info_album"></span><br>
<div class="showarea">
<div class="info_lyric"></div>
</div>
</div>
</div>
<audio src=""></audio>
</main>
3. 尾部
尾部进度条样式需要注意,进度条一般都是点线组成。
<footer>
<ul class="control">
<li class="prev"></li>
<li class="play"></li>
<li class="next"></li>
</ul>
<div class="progress">
<div class="progress_top">
<span class="progress_name"></span>
<span class="progress_time"></span>
</div>
<div class="progress_bar noclick">
<div class="progress_line"></div>
<div class="progress_dot"></div>
</div>
</div>
<ul class="funcs">
<li class="mode"></li>
<li class="like"></li>
<li class="load"></li>
<li class="comment"></li>
<li class="toggle"></li>
<li class="voice"></li>
<div class="voice_bar">
<div class="voice_line"></div>
<div class="voice_dot"></div>
</div>
</ul>
</footer>
4. 遮罩效果
<div class="mask_bg"></div>
<div class="mask"></div>
样式实现
1. 头部
主要负责整个页面的初始化以及头部的样式,opacity为透明度,搭配:hover可实现一些不错的效果。user-select: none不让用户选中,减少无效操作。
* {
margin: 0;
padding: 0;
}
html {
font-size: 14px;
height: 100%;
}
a {
text-decoration: none;
color: white;
}
li {
list-style: none;
}
header {
width: 100%;
height: 50px;
user-select: none;
}
.logo img {
float: left;
margin: 20px;
width: 50px;
}
header > ul {
float: right;
}
header > ul > li {
float: left;
margin-right: 30px;
line-height: 50px;
opacity: .5;
}
header > ul > li:hover {
opacity: 1;
}
2. 主体部分
2.1 顶部导航
main {
user-select: none;
height: 600px;
width: 1200px;
margin: 0 auto;
}
.music {
width: 800px;
height: 100%;
float: left;
}
.music_nav {
width: 100%;
height: 60px;
padding-top: 10px;
margin-left: 20px;
}
.music_nav > li {
box-sizing: border-box;
float: left;
width: 140px;
color: white;
opacity: .5;
border: 1px solid #ffffff;
line-height: 30px;
margin-left: 10px;
text-align: center;
border-radius: 5px;
cursor: pointer;
}
.music_nav > li > span {
display: inline-block;
width: 18px;
height: 18px;
background: url("img/icon_sprite.png") no-repeat 0 0;
margin: 0 5px -4px 0;
}
.music_nav > li:nth-child(1) > span {
background-position: -60px -20px;
}
.music_nav > li:nth-child(2) > span {
background-position: -20px -20px;
}
.music_nav > li:nth-child(3) > span {
background-position: -40px -240px;
}
.music_nav > li:nth-child(4) > span {
background-position: -100px -20px;
}
.music_nav > li:nth-child(5) > span {
background-position: -40px -300px;
}
.music_nav > li:hover {
opacity: 1;
}
2.2 音乐列表
鼠标悬停到哪首歌曲,哪首歌曲的子菜单就会出现,时长会被替代为删除按钮。
.music_list {
height: 480px;
overflow: auto;
width: 800px;
}
.musics {
width: 780px;
height: 80px;
color: white;
position: relative;
}
.musics > li {
position: absolute;
opacity: .5;
}
.musics_li2 {
opacity: 1 !important;
}
.list_check i {
display: inline-block;
width: 14px;
height: 14px;
border: 1px solid #fff;
opacity: .5;
}
.current_i {
background: url("img/duihao.png") no-repeat;
background-size: 13px 13px;
opacity: 1 !important;
}
.list_check {
top: 32px;
left: 30px;
}
.list_num {
top: 30px;
left: 100px;
}
.list_num2 {
background: url("img/wave.gif") no-repeat 0 0;
color: transparent;
}
.list_song {
top: 30px;
left: 120px;
}
.list_name {
top: 30px;
left: 500px;
}
.list_time {
top: 30px;
left: 700px;
}
.musics > ul > a {
opacity: .5;
display: inline-block;
width: 36px;
height: 36px;
border-radius: 50%;
background: url("img/icon_list_menu.png") no-repeat 0 0;
}
.musics > ul > a:hover {
opacity: 1;
}
.musics > ul {
display: none;
position: absolute;
left: 300px;
top: 20px;
}
.musics > ul .list_play {
background-position: -120px 0;
}
.list_play2 {
background-position: -120px -200px !important;
}
.list_add {
background-position: -120px -80px !important;
}
.list_down {
background-position: -120px -120px !important;
}
.list_share {
background-position: -120px -40px !important;
}
.list_drop {
background-position: -120px -160px !important;
position: absolute;
top: 0;
left: 435px;
}
2.3 歌曲信息
.info {
width: 400px;
height: 100%;
float: right;
}
.info_img {
width: 200px;
height: 180px;
margin: 100px 0 0 100px;
background: url("img/album_cover_player.png");
}
.info_img > img {
width: 200px;
height: 180px;
margin-left: -20px;
}
.info_words {
line-height: 20px;
text-align: center;
opacity: .7;
padding-top: 20px;
}
.info_lryic {
opacity: .7;
text-align: center;
}
.showarea{
margin-top: 50px;
height: 100px;
overflow: hidden;
}
.info_lyric li {
line-height: 20px;
}
.info_words a {
color: #000;
}
3. 尾部
footer {
user-select: none;
width: 1200px;
height: 50px;
margin: 0 auto;
}
footer li {
background: url("img/player.png") no-repeat 0 0;
opacity: .5;
}
footer li:hover {
opacity: 1;
}
.control {
float: left;
height: 50px;
padding-top: 10px;
margin-left: 20px;
}
.control li {
float: left;
margin-left: 30px;
line-height: 50px;
}
.prev {
width: 19px;
height: 20px;
background-position: 0 -30px !important;
margin-top: 5px;
}
.play {
width: 21px;
height: 29px;
background-position: 0 0;
}
.play2 {
background-position: -30px 0 !important;
}
.next {
width: 19px;
height: 20px;
background-position: 0 -52px !important;
margin-top: 5px;
}
.funcs {
height: 50px;
float: left;
position: relative;
}
.funcs li {
float: left;
line-height: 50px;
margin-left: 30px;
}
.mode {
width: 26px;
height: 25px;
background-position: 0 -205px;
margin-top: 13px;
}
.like {
width: 24px;
height: 21px;
background-position: 0 -96px;
margin-top: 15px;
}
.load {
width: 22px;
height: 21px;
background-position: 0 -120px;
margin-top: 13px;
}
.comment {
width: 24px;
height: 24px;
background-position: 0 -400px;
margin-top: 13px;
}
.toggle {
width: 74px;
height: 27px;
background-position: 0 -281px;
margin-top: 10px;
}
.voice {
width: 26px;
height: 21px;
background-position: 0 -144px;
margin-top: 13px;
}
.voice2 {
background-position: 0 -182px !important;
}
.voice_bar {
position: absolute;
right: -70px;
top: 22px;
height: 3px;
width: 60px;
background-color: rgba(255, 255, 255, .5);
}
.voice_bar .voice_line {
height: 100%;
width: 20px;
background-color: #ffffff;
}
.voice_bar .voice_dot {
height: 10px;
width: 10px;
background-color: #ffffff;
border-radius: 50%;
position: absolute;
top: -3px;
left: 20px;
}
.progress {
width: 500px;
height: 50px;
float: left;
margin-left: 50px;
}
.progress_top {
width: 100%;
height: 30px;
line-height: 30px;
text-align: center;
}
.progress_top span {
color: #ffffff;
opacity: .5;
}
.progress_top .progress_name {
float: left;
}
.progress_top .progress_name:hover {
opacity: 1;
}
.progress_top .progress_time {
float: right;
}
.progress_bar {
margin-top: 5px;
width: 100%;
height: 3px;
background: rgba(255, 255, 255, 0.5);
position: relative;
}
.progress_bar .progress_line {
width: 0;
height: 100%;
background: #fff;
}
.progress_bar .progress_dot {
width: 14px;
height: 14px;
border-radius: 50%;
background-color: #fff;
position: absolute;
top: -6px;
left: 0;
}
.noclick {
pointer-events: none;
}
.mask_bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url("img/傅如乔.png") no-repeat;
background-size: cover;
z-index: -1;
filter: blur(50px);
}
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
opacity: .5;
z-index: -1;
}
.cur {
color: #00ff00;
font-weight: bold;
}
总结
先布好局,才能好好写脚本。