<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="./bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet">
</head>
<style>
a{
color:antiquewhite;
text-decoration: none;
}
a:hover{
color: white;
text-decoration: none;
}
a1{
color:black;
text-decoration: none;
}
a1:hover{
color: white;
text-decoration: none;
}
.goback {
position: fixed;
top: 600px;
left: 50%;
/* margin-right: -23px; */
margin-left: 620px;
width: 46px;
height: 46px;
background-color: #777;
font-size: 26px;
text-align: center;
line-height: 40px;
color: #ccc;
cursor: pointer;
}
</style>
<script>
window.addEventListener('load', function() {
// 1.获取元素
var goback = document.querySelector('.goback');
// 2.注册点击事件
goback.addEventListener('click', function() {
animate(window, 0);
});
function animate(obj, target, callback) {
// console.log(callback); callback = function() {} 调用的时候 callback()
// 先清除以前的定时器,只保留当前的一个定时器执行
clearInterval(obj.timer);
obj.timer = setInterval(function() {
// 步长值写到定时器的里面
// 把我们步长值改为整数 不要出现小数的问题
// var step = Math.ceil((target - obj.offsetLeft) / 10);
var step = (target - window.pageYOffset) / 10;
step = step > 0 ? Math.ceil(step) : Math.floor(step);
if (window.pageYOffset == target) {
// 停止动画 本质是停止定时器
clearInterval(obj.timer);
// 回调函数写到定时器结束里面
// if (callback) {
// // 调用函数
// callback();
// }
callback && callback();
}
// 把每次加1 这个步长值改为一个慢慢变小的值 步长公式:(目标值 - 现在的位置) / 10
obj.style.top = window.scroll(0, window.pageYOffset + step); // window.scroll里不用加 px
}, 15);
}
})
</script>
<body>
<div style="width:100%;background-color:rebeccapurple; ">
<div class="navbar" style="background-color: black;text-align: center;color: white;height: 20px;">
<a href="#">Bootstrap中文网</a>   
<a href="#">Bootstrap2中文文档</a>   
<a href="#">Bootstrap3中文文档</a>   
<a href="#">Bootstrap4中文文档</a>   
<a href="#">Less教程</a>   
<a href="#">JQery API</a>   
<a href="#">网站实例</a>            
<a href="#">关于</a>   
</div>
<div style="width: 100%;height: 300px;background-color:rebeccapurple;text-align: center;color: white;margin-top: 50px;">
<p><h1 >Bootstrap</h1></p>
<p>简洁、直观、强悍的前端开发框架,让web开发更迅速、简单。</p>
<button style="background-color:#31b0d5;width: 300px;height: 50px;margin-top: 20px;">bootstrap中文文档</button>
</div>
<div style="width: 100%;height: 30px;background-color: #cccccc;text-align: center;color: black" >
<P>Bootstrap问答社区    |     新浪微博: @Bootstrap2中文网</p>
</div>
</div>
<div class="container" style="background-color: white;">
<div class="row text-center">
<p class="col-md-12 "style="background-color:white">
<h1>Bootstrap相关优质项目推荐</h1>
</p>
<p class="col-md-12 "style="background-color:white">
<h6>这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的</h6>
</p>
</div>
<div class="row" style="margin-top: 50px; ">
<div class="col-md-3"style="width: 220px;height: 350px;border: 1px solid black;" >
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/1.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>优站精选</h2></p>
<p>Bootstrap 网站实例</p>
<p><h6>
Bootstrap 优站精选频道收集了众多基于 Bootstrap 构建、设计精美的、有创意的网站。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-1"style="width: 220px;height: 350px;border: 1px solid black;" >
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/2.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>Webpack</h2></p>
<p>是前端资源模块化管理和打包工具</p>
<p><h6>
Webpack 是当下最热门的前端资源模块化管理和打包工具。它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-2"style="width: 220px;height: 350px;border: 1px solid black;">
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/3.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>React</h2></p>
<p>用于构建用户界面的 JavaScript 框架</p>
<p><h6>
React 起源于 Facebook 的内部项目,是一个用于构建用户界面的 JavaScript 库。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-3"style="width: 220px;height: 350px;border: 1px solid black;">
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/4.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>TypeScript </h2></p>
<p>中文手册</p>
<p><h6>
TypeScript 是由微软开源的编程语言。它是 JavaScript 的一个超集,而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程。
</h6>
</p>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-md-3"style="width: 220px;height: 350px;border: 1px solid black;margin-top: 50px;" >
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/5.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>jQuery API </h2></p>
<p>中文手册</p>
<p><h6>
根据最新的 jQuery 1.11.x 和 2.1.x 版本翻译的 jQuery API 中文文档/手册。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-1"style="width: 220px;height: 350px;border: 1px solid black;margin-top: 50px;" >
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/6.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>Next.js</h2></p>
<p>中文文档</p>
<p><h6>
Next.js 是一个轻量级的 React 服务端渲染应用框架。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-2"style="width: 220px;height: 350px;border: 1px solid black;margin-top: 50px;">
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/7.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>Babel </h2></p>
<p>是一个 JavaScript 编译器。</p>
<p><h6>
Babel 是一个 JavaScript 编译器。Babel 通过语法转换器支持最新版本的 JavaScript 语法。
</h6>
</p>
</div>
</div>
<div class="col-md-3 col-md-push-3"style="width: 220px;height: 350px;border: 1px solid black;margin-top: 50px;">
<div style="width: 190px;height: 150px;background-color: red;margin-top: 5px;">
<img src="img/8.png" style="width: 190px;height: 150px;">
</div>
<div style="width: 200px;text-align: center">
<p><h2>Node.js</h2></p>
<p>中文文档 / 手册</p>
<p><h6>
Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型,使其轻量又高效。
</h6></p>
</div>
</div>
</div>
</div>
<div style="width: 100%;height: 50px;">
<div class="goback">▲</div>
</div>
</body>
</html>