midnight.js 介绍
midnight.js是在 页面 滚动时控制多 标题 设计的开关jQuery 插件 ,所以你总是有 一个 头与它下面的 内容 层叠,看起来 效果 很不错。Midnight.js 可以让你轻松实现这种切换固定头的 效果 。
创建 一个 固定 标题
<nav class="fixed">
<a class=" logo "> logo </a>
</nav>
确保 标题 位置固定然后选取你 页面 有导航栏的部分, 添加 数据-midnight="你的类",这个类正好是你的 标题 要使用的风格。如果你不使用 属性 或只留下空白。 默 认的 标题 将被用于这部分。
<section data-midnight="white">
<h1>A section with a dark background,so a white nav would look better here</h1>
</section>
<div data-midnight="blue">
<h1>A blue nav looks better here</h1>
</div>
<footer>
<h1>This will just use the default header</h1>
</footer>
多个 标题 在必要时将创建基于这些部分中声明的类。
你可以在你的css样式类.midnightHeader使用。您的类(类替换为正确的)。例如:
.midnightHeader.default {
background: none;
color: black;
}
.midnightHeader.white {
background: white;
color: black;
}
.midnightHeader.blue {
background: blue;
color: white;
}
.midnightHeader.red {
background: red;
color: white;
}
加载并初始化它
<script src="midnight.jquery.js"></script>
<script>
// Start midnight
$(document).ready(function(){
// Change this to the correct selector for your nav.
$('nav.fixed').midnight();
});
</script>
网站地址 : http://aerolab.github.io/midnight.js/
GitHub: https://github.com/Aerolab/midnight.js
网站描述: 在 页面 滚动的时候实现多个头设计之 间的 切换 插件
midnight.js官方网站
官方网站: http://aerolab.github.io/midnight.js/
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。