一、知识点

①background-attachment属性设置背景图像是否固定或者随着页面的其余部分滚动。scroll默认值。背景图像会随着页面其余部分的滚动而移动。fixed当页面的其余部分滚动时,背景图像不会移动。

②视觉插件stellar

  • 视差滚动指网页滚动过程中,多层次的元素进行不同程度的移动,视觉上形成立体运动效果的网页展示技术。主要核心就是前景和背景以不同速度移动,从而创造出3D效果。利用background-attachment属性实现。stellar.js是一个jQuery插件,能很容易地给网站添加视差滚动效果
  • 引入js包
<script src="path/to/jquery/jquery.min.js"></script>
<script src="path/to/jquery.stellar.min.js"></script>
  • 引用HTML和css样式
<div class="content" id="content1">
<p>TEXT HERE</p>
</div>
<div class="content" id="content2">
<p>TEXT HERE</p>
</div>
<div class="content" id="content3" data-stellar-background-ratio="0.5">
<p>TEXT HERE</p>
</div>
<div class="content" id="content4" data-stellar-background-ratio="0.5">
<p>TEXT HERE</p>
</div>
<div class="content" id="content5" data-stellar-background-ratio="0.5">
<p>TEXT HERE</p>
</div>
<div class="content" id="content6" data-stellar-background-ratio="0.5">
<p>TEXT HERE</p>
</div>
//css样式中设置content背景等
  • js 调用函数
$.stellar({
horizontalScrolling: false,
responsive: true
});
  • 详细参数

二、思路

①页面基础结构

②导航部分

③展示部分

④语音部分、文件部分、兴趣部分

⑤底部部分

⑥使用插件stellar

⑦文件目录结构

三、代码实现

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>QQ首页</title>
<link rel="stylesheet" href="css/index.css">
<!-- [if lte IE 8] -->
<script src="js/html5shiv.js"></script>
<!-- endif -->
</head>
<body>
<!-- 导航 -->
<nav class="qq_nav">
<div class="wrapper">
<a href="#" class="logo"></a>
<ul class="nav">
<li><a href="#">首页</a></li>
<li><a href="#">下载</a></li>
<li><a href="#">动态</a></li>
</ul>
<a href="#" class="register">注册</a>
<div class="other">
<ul>
<li><a href="#">QQ安全</a></li>
<li><a href="#">QQ会员</a></li>
<li><a href="#">登录</a></li>
</ul>
<span>当前在线人数:288,597,005</span>
</div>
</div>
</nav>
<!-- 展示 -->
<section class="qq_banner">
<img src="data:images/banner-logo.png" alt="">
<img src="data:images/banner-dowload.png" alt="">
<img src="data:images/banner-list.png" alt="">
<img src="data:images/banner-produst.png" alt="">
</section>
<!-- 语音 -->
<section class="qq_sound">
<h1>I'm QQ - 每一天,乐在沟通</h1>
<div class="bg" data-stellar-background-ratio="0.3"></div>
<div class="content">
<div class="ipone"></div>
<h2>沟通,是跨越<br>千山万水的亲切声音</h2>
<p>无论何时何地,你都能自由享受QQ在各类<br>终端上带来的高清通话,与好友一起想聊多久聊多久</p>
</div>
</section>
<!-- 文件 -->
<section class="qq_file">
<div class="bg" data-stellar-background-ratio="0.3"></div>
<div class="content">
<div class="mac"></div>
<h2>沟通,是随时随地<br>爽快收发</h2>
<p>通过QQ,电脑和手机上的文件都能收发自如,<br>更有手机在线查阅,轻松你的工作和生活。</p>
</div>
</section>
<!-- 兴趣 -->
<section class="qq_interest">
<div class="bg" data-stellar-background-ratio="0.3"></div>
<div class="content">
<div class="phone"></div>
<h2>沟通,是志同道合<br>的他们放肆青春</h2>
<p>即使世界很大,你也不会孤单,在兴趣部落<br>有和你一样的人,期待着和你一起发现精彩</p>
</div>
</section>
<!--S footer-->
<footer class="qq_footer">
<img src="data:images/foot.png" alt="">
</footer>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.stellar.js"></script>
<script src="js/index.js"></script>
</body>
</html>

html

/* =============reset css============== */
*{
/*通配符选择器,案例特殊处理,实际开发少用 */
margin: 0;
padding: 0;
}
body{
font-size: 14px;
font-family: "Microsoft YaHei",sans-serif;
color: #333;
}
ul{
list-style: none;
}
a{
color: #333;
text-decoration: none;
}
/* =============moudle css============= */
/* nav start */
.qq_nav{
height: 150px;
background: url("../images/nav-bg.png") repeat-x;
}
.qq_nav .wrapper{
width: 1080px;
height: 75px;
margin: 0 auto;
}
.qq_nav .wrapper .logo{
width: 100px;
height: 75px;
background: url("../images/nav-logo.png") no-repeat center;
float: left;
}
.qq_nav .wrapper .nav{
float: left;
}
.qq_nav .wrapper .nav li{
float: left;
font-size: 18px;
line-height: 75px;
margin-left: 20px;
}
.qq_nav .wrapper .nav a{
display: block;
padding: 0 20px;
}
.qq_nav .wrapper .nav a:hover{
background: #12b7f5;
}
.qq_nav .wrapper .register{
float: left;
height: 36px;
width: 96px;
text-align: center;
line-height: 36px;
font-size: 16px;
background: #12b7f5;
color: #fff;
border-radius: 18px;
margin: 19px 0 0 200px;
}
.qq_nav .wrapper .other{
float: left;
width: 250px;
height: 75px;
}
.qq_nav .wrapper .other ul{
width: 250px;
}
.qq_nav .wrapper .other li{
float: left;
margin-left: 40px;
}
.qq_nav .wrapper .other a{
font-size: 14px;
text-shadow: 0 0 2px #333;
height: 50px;
line-height: 50px;
}
.qq_nav .wrapper .other span{
float: right;
} /* banner start */
.qq_banner{
height: 1100px;
background: url("../images/banner-bg.jpg") no-repeat center top;
padding-top: 150px;
}
.qq_banner img{
display: block;
margin: 20px auto 0;
}
.qq_banner img:last-child{
width: 100%;/* 自适应,等比例缩放 */
} /* qq_sound Start */
.qq_sound h1{
height: 300px;
background:url("../images/sound-text.png") no-repeat center/cover;
font-size: 0;
}
.qq_sound .bg{
height: 500px;
background: url("../images/sound-bg.jpg") no-repeat center/cover;
}
.qq_sound .content{
height: 500px;
width: 980px;
margin: 0 auto;
position: relative;
}
.qq_sound .content .ipone{
position: absolute;
left: 0;
top: -200px;
width: 700px;
height: 700px;
background: url("../images/sound-phone.png") no-repeat center top/cover;
}
.qq_sound .content h2{
float: right;
padding-top: 100px;
width: 500px;
text-align: center;
font-size: 40px;
}
.qq_sound .content p{
padding-top: 50px;
float: right;
width: 500px;
text-align: center;
font-size: 18px;
text-shadow: 0 0 2px #333;
} /* qq_file start */
.qq_file .bg{
height: 500px;
background: url("../images/file-bg.jpg") no-repeat center/cover;
}
.qq_file .content{
height: 500px;
width: 980px;
margin: 0 auto;
position: relative;
}
.qq_file .content .mac{
position: absolute;
right: -60px;
top: 100px;
width: 600px;
height: 340px;
background: url("../images/file-mac.png") no-repeat center top/cover;
}
.qq_file .content h2{
float: left;
padding-top: 100px;
width: 500px;
text-align: center;
font-size: 40px;
}
.qq_file .content p{
padding-top: 50px;
float: left;
width: 500px;
text-align: center;
font-size: 18px;
text-shadow: 0 0 2px #333;
} /* qq_interest start */
.qq_interest .bg{
height: 500px;
background: url("../images/in-bg.jpg") no-repeat center/cover;
}
.qq_interest .content{
height: 500px;
width: 980px;
margin: 0 auto;
position: relative;
}
.qq_interest .content .phone{
position: absolute;
left: 0px;
top: 0px;
width: 344px;
height: 500px;
background: url("../images/in-phone.png") no-repeat center top/cover;
}
.qq_interest .content h2{
float: right;
padding-top: 100px;
width: 500px;
text-align: center;
font-size: 40px;
}
.qq_interest .content p{
padding-top: 50px;
float: right;
width: 500px;
text-align: center;
font-size: 18px;
text-shadow: 0 0 2px #333;
}
/*footer 图片代替省略*/
/* 插件 */
.qq_sound .bg,.qq_file .bg, .qq_interest.bg{
background-attachment: fixed;
}

css

$(function(){
/**
* 1.引入
* 2.结构data-stellar-background-ratio="0.3"
* 3.样式bg 需要background-attachment: fixed;
* 4.初始化插件
*/
$.stellar({
horizontalScrolling: false,
responsive: true
});
});

js

四、效果展示

最新文章

  1. HTML5 音频播放器-Javascript代码(短小精悍)
  2. linux expect命令使用入门
  3. http://chenzhou123520.iteye.com/blog/1811340
  4. 转载 - LINUX下查看CPU使用率的命令
  5. python解无忧公主的数学时间097.py
  6. 使用定时器实现JavaScript的延期执行或重复执行
  7. 基于ZooKeeper的分布式Session实现(转)
  8. SHOW SLAVE STATUS几个常见参数
  9. Ubuntu下VSFTPD(五)(匿名FTP设置方法)
  10. 在今天,我们为什么还要做一个CMS
  11. 飞锐GIS开发基础系列
  12. 【原创教程】虎咽CSS
  13. c#中传递参数前加out
  14. 关于post与get请求参数存在特殊字符问题
  15. BC高精确度函数使用。
  16. IIR滤波器软件实现(Matlab+C++)
  17. 选择困难症的福音——团队Scrum冲刺阶段-Day 3
  18. FHQ Treap小结(神级数据结构!)
  19. vue.js实战(文摘)
  20. 复习 C++ 中类的函数指针

热门文章

  1. commonjs 与 es6相关Module语法的区别
  2. PHP7预编译mysqli查询操作
  3. go语言实现分布式id生成器
  4. python进程不能并行的原因,进程阻塞
  5. Js网站开发学习第一天
  6. 编写订单支付api中遇到的问题
  7. TP5框架模块绑定二级域名
  8. S3cmd
  9. AQS的子类在各个同步工具类中的使用情况
  10. 零基础Python教程-详说list有序集合