本教程是一个H5音乐播放的详情页制作,实现了H5音乐播放,音轨的跳动,已经较为酷炫的UI界面。
通过本教程,您会学到:
1、H5音乐播放 (带音轨)
2、iconfont字体图标库
3、div+css网页布局
前端技术:js,jQuery,css ,bootstrap,iconfont
后台技术:php
数据库:mysql
首先,看一下页面的布局:

基本上用div+css的技术就可以实现。
1.1 标题区域

先新建一个detail.php (如果没有php的环境,就把后缀名修改为.html即可)。

<html>
<head>
<meta charset="utf-8">
<title>音乐详情页</title>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
我们设置标题区域的可见宽度为950px,居中。背景色设置为黑色(#000)


效果:

现在做登录和注册模块,考虑画一个div并且向右浮动。



这个效果非常丑,因为a标签默认就有一个蓝色的样式和下划线,所以,我们需要对这两个a标签的样式进行调整。



我们把logo和菜单看成一个整体,就header中就是往左浮动的DIV。



效果:

在这个DIV中,靠左的是一个LOGO (150px * 60px)。




因为字体默认是黑色的,所以还需要对logo的div做一点css修改。

效果:

画好了LOGO,在它的右边,就是菜单选项。

至于菜单项,我们一般采用ul , li 来制作。

效果:

同样的,要去修改一下这里a标签的样式。


又因为li元素默认是有小圆点的。我们需要把li的小圆点去掉,同时设置高度和header保持一致,都为60px。


接下来,我们要引入iconfont字体图标库,每一个菜单项左边,都需要一个彩色图标。


把这个文件夹拷贝到项目根目录:

再在detail.php中引入其中的css文件和js文件。

引入彩色图标。


我们再给这个svg图标添加一个左浮动:

可以看到首页两个字跑到上面的去了,那是因为我们还没有给li元素加行高。
现在,就让首页两个字垂直居中,方法就是给li加上60px的行高。

我们还发现,li元素占据了一整行:

原来,li也是块级元素,会默认占满一整行,因此,我们需要对li进行一些修饰,比如,将其宽度设置为100px。

加上去以后,发现li被挤下来了:

这是因为li元素的外层ul元素,我们没有加上浮动,因此被挤下来了。解决方法就是给ul加上左浮动,让你紧跟在logo的右侧。

其他几个菜单项也依次类推:
<ul>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-squirtle"></use>
</svg>
首页
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-squirtle"></use>
</svg>
专题
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-squirtle"></use>
</svg>
单曲
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-squirtle"></use>
</svg>
论坛
</a>
</li>
</ul>
效果:

发现每一个菜单项(li)竖着排下来了,因此li也需要加浮动。

然后,给每一个li加一点右边距:

效果:

然后再把图标换成其他的彩色图标。
<div class="h_left">
<div class="logo">150X60的LOGO</div>
<ul>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-squirtle"></use>
</svg>
首页
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-pikachu-"></use>
</svg>
专题
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-bullbasaur"></use>
</svg>
单曲
</a>
</li>
<li>
<a href="javascript:void(0)">
<svg style="width:60px;height:60px;float: left;" class="icon" aria-hidden="true">
<use xlink:href="#icon-aoliao"></use>
</svg>
论坛
</a>
</li>
</ul>
</div>
本章结束。
网友评论