滚动固定TAB在顶部显示
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title>Examples</title>
- <meta name="description" content="">
- <meta name="keywords" content="">
- <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v20/base.css"/>
- <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v20/public.css"/>
- <link rel="stylesheet" href="http://pcss1.4008000000.com/app_css/4008000000/v10/zaixiangoumai/baoxian/lvyoubaoxian_bbm.css"/>
- <script type="text/javascript" src="http://pscript1.4008000000.com/app_js/paui/1.0.1/build/pa.ui.min.js"></script>
- </head>
- <body>
- <div style="height:500px;"></div>
- <div class="page_Tab_title" id="page_Tab_title" style="margin-top: 0px; position: absolute;">
- <div class="page_Tab">
- <ul class="page_Tab_nav c">
- <li class="cut">保障说明</li>
- <li>常见问题</li>
- <li>特别申明</li>
- <li>客户评价</li>
- </ul>
- <!-- 分享 -->
- <div class="fenxiang">
- <span>该产品分享至:</span>
- <a class="jiathis_button_weixin weixin" title="微信" otitle="微信-TAB选卡" otype="button" id="T-weixin"><span class="jiathis_txt jiathis_separator jtico jtico_weixin">微信</span></a>
- <a class="jiathis_button_tsina sina" title="新浪微博" otitle="新浪微博-TAB选卡" otype="button" id="T-sina"><span class="jiathis_txt jiathis_separator jtico jtico_tsina">新浪微博</span></a>
- <!--<a class="text" href="javascript:;" title="加入收藏" otitle="加入收藏" otype="button"></a>
- <a class="favorite" href="javascript:;" title="加入收藏" otitle="加入收藏" otype="button" onclick="AddFavorite(window.location,document.title)">加入收藏</a>
- <span class="count"></span>-->
- </div>
- <!-- 分享 END -->
- </div>
- <!-- 价格 -->
- <div class="pro-name">
- <div class="fr pro-price">
- <a href="http://www.pingan.com/pa18shopnst/productCenterNew/apply.shtml?productCode=PAY370" class="dib proPrice_btn" title="立即购买" otitle="吃货旅游保险-立即购买-上" otype="entry" target="_blank" onclick="hrefChangeByMediaSource(this);" id="T-ljgm-chihuo">立即购买</a>
- </div>
- <div class="fl pro-title">
- <h2>【吃货旅游保险】<span>保费:<strong>20元</strong>人</span><span>保险期限:3天</span><span>适用人群:-70周岁</span></h2>
- </div>
- </div>
- <!-- 价格 END -->
- </div>
- <div class="page-width">
- <!-- 保障说明 -->
- <div class="bz-table" id="page_Tab_cell0">
- <div style="height:500px;"></div>
- </div>
- <!-- 保障说明 END-->
- <!-- 保障疑问 -->
- <!-- 保障疑问 END-->
- <!--常见问题-->
- <div class="page_tab_cont" id="page_Tab_cell1">
- <div style="height:500px;"></div>
- </div>
- <!--常见问题 END-->
- <!--特别声明-->
- <div class="page_tab_cont" id="page_Tab_cell2">
- <div style="height:500px;"></div>
- </div>
- <!--特别声明 END-->
- <!--客户评价-->
- <div class="page_tab_cont mt20" id="page_Tab_cell3">
- <div style="height:500px;"></div>
- </div>
- <!--客户评价 END-->
- </div>
- <div style="height:2000px;"></div>
- <script>
- //随移固定 1.作用id 2.起始高度 3.结束高度 4.上边距or下边距 5.垂直边距
- function scr_fixed(id, startH, finishH, vertical_type, mar) {
- var obj = document.getElementById(id),
- llq, inNun = false, inNun2 = false, inNun3 = false;
- if(document.all) {
- var browser = navigator.appName,
- b_version = navigator.appVersion,
- version = b_version.split(";"),
- trim_Version = version[].replace(/[ ]/g, "");
- if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
- llq = "ie6";
- } else {
- llq = "ie";
- }
- } else {
- llq = "noie";
- }
- if (vertical_type == "b") {
- startH -= document.documentElement.clientHeight;
- }
- function scrollFunc(){
- var allH = document.body.scrollHeight - finishH,
- scroH = document.documentElement.scrollTop + document.body.scrollTop;
- if (vertical_type == "b") {
- allH -= document.documentElement.clientHeight;
- }
- //右侧移动
- if (scroH >= startH && scroH < allH) {
- if (llq == "ie6") {
- if (vertical_type == "t") {
- obj.style.cssText = "margin-top:" + mar + "px; position:absolute; top:" + scroH + "px";
- } else if (vertical_type == "b") {
- obj.style.cssText = "margin-bottom:" + mar + "px; position:absolute; top:" + scroH + "px";
- }
- } else {
- if (!inNun) {
- if (vertical_type == "t") {
- obj.style.cssText = "margin-top:" + mar + "px; top:0; position:fixed;";
- } else if (vertical_type == "b") {
- obj.style.cssText = "margin-bottom:" + mar + "px; top:auto; bottom:0; position:fixed;";
- }
- inNun = true;
- } else return false;
- }
- inNun2 = false;
- inNun3 = false;
- } else if (scroH >= allH) {
- if (!inNun3) {
- if (vertical_type == "t") {
- obj.style.cssText = "margin-top:0; position:absolute; top:" + allH + "px";
- } else if (vertical_type == "b") {
- obj.style.cssText = "margin-bottom:0; position:absolute; top:auto; bottom:" + -allH + "px";
- }
- inNun3 = true;
- } else return false;
- inNun = false;
- } else {
- inNun = false;
- if (llq == "ie6") {
- if (vertical_type == "t") {
- obj.style.cssText = "margin-top:0; position:absolute;";
- } else if (vertical_type == "b") {
- obj.style.cssText = "margin-bottom:0; position:absolute;";
- }
- } else {
- if (!inNun2) {
- if (vertical_type == "t") {
- obj.style.cssText = "margin-top:0; position:absolute;";
- } else if (vertical_type == "b") {
- obj.style.cssText = "margin-bottom:0; position:absolute;";
- }
- inNun2 = true;
- } else return false;
- }
- }
- }
- if(window.addEventListener){
- window.addEventListener('scroll', scrollFunc);
- } else {
- window.attachEvent('onscroll', scrollFunc);
- }
- if(document.documentElement.scrollTop + document.body.scrollTop == ){
- scrollFunc();
- }
- }
- // 滚动导航分块
- function orderScroll(opt){
- this.options = {
- menu: "", //要固定的顶部导航栏的ID
- type: 'scroll', //类型, scroll:滚动 tab:tab切换
- tab_hide: true, //若选择tab方式,true为默认隐藏非当前分块,false为默认不隐藏非当前分块
- vertical: 't', //附着在顶部或者底部 "t" or "b"
- cell: "", //分块,选择器ID前缀,后加数字确定次序——分块类型请用一种
- cell_class: "", //分块,由相同class组成,按次序排——分块类型请用一种
- cut_class: "cut", //选中样式名
- btn: "", //导航栏中控制显隐的按钮选择器
- cell_t: , //分块距离顶部高度——单数字视为每个分块距离顶部高度一样,也可设置为数组定义不同的高度
- start_h: undefined, //开始高度
- end_h: , //结束高度
- animate: //滚动速度
- };
- for(var i in opt){
- if(opt[i] != undefined){
- this.options[i] = opt[i];
- }
- }
- this._start = function(){
- var self = this,
- opt = self.options,
- menu = opt.menu,
- $menu = $('#' + menu),
- $menuH = $menu.outerHeight(),
- start_h = opt.start_h || $menu.offset().top,
- cell = "#" + opt.cell,
- cell_class = '.' + opt.cell_class,
- cell_t = opt.cell_t,
- vertical = opt.vertical,
- $btn = $(opt.btn),
- length = $menu.find('li').length,
- cellH = new Array(length),
- obj = new Array(length),
- n, i, contain, nowH;
- if(vertical == 'b'){
- start_h += $menuH;
- }
- //随移固定 1.作用id 2.起始高度 3.结束高度 4.上边距or下边距 5.垂直边距
- scr_fixed(menu,start_h,opt.end_h,vertical,);
- if (vertical == "b") {
- start_h -= $(window).height();
- opt.end_h += $(window).height();
- }
- // 添加占位div
- if($menu.next().attr('class') != (menu + "_stay") && $menu.next().height() != $menuH){
- $menu.after('<div class="' + menu +'_stay" style="height:' + $menuH + 'px;"></div>');
- }
- if(typeof cell_t == 'number'){
- n = cell_t;
- cell_t = new Array(length);
- for(i = ; i < length; i++){
- cell_t[i] = n;
- }
- }
- for(i = ; i < length; i++){
- obj[i] = (cell_class == '.') ? $(cell + i) : $(cell_class).eq(i);
- }
- function countPos(){
- for(i = ; i < length; i++){
- cellH[i] = obj[i].length ? obj[i].offset().top - $menuH - cell_t[i] : ;
- if (vertical == "b") {
- cellH[i] += $menuH;
- }
- }
- }
- countPos();
- //tab方式
- if(opt.type == "tab"){
- if(opt.tab_hide){
- for(i = ; i < length; i++){
- obj[i].hide();
- }
- obj[].show();
- }
- $menu.find('li').each(function(){
- var $this = $(this),
- index = $this.index();
- $(this).click(function(){
- $menu.find('li').removeClass(opt.cut_class).eq(index).addClass(opt.cut_class);
- $('html,body').stop().animate({scrollTop:cellH[] + }, opt.animate);
- obj[index].show().siblings().hide();
- })
- })
- }
- function judge_statu(){
- countPos();
- nowH = $(this).scrollTop();
- for(i = ; i < length; i++){
- contain = i == length- ? : cellH[i + ];
- if(nowH > cellH[i] && nowH < contain){
- $menu.find('li').removeClass(opt.cut_class).eq(i).addClass(opt.cut_class);
- break;
- }
- }
- }
- $(window).scroll(function(){
- if($(this).scrollTop() >= start_h && $(this).scrollTop() <= document.body.scrollHeight - opt.end_h){
- if(opt.type == "scroll"){
- judge_statu();
- }
- $btn.show();
- }else{
- $btn.hide();
- }
- })
- if(opt.type == "scroll"){
- judge_statu();
- $menu.find('li').each(function(){
- var $this = $(this),
- index = $this.index();
- $(this).click(function(){
- $('html,body').stop().animate({scrollTop:cellH[index] + }, opt.animate);
- })
- })
- }
- }
- this._start();
- }
- orderScroll.prototype = {
- }
- // 随屏滚动固定菜单并导航分块 0811
- var scroll_order = new orderScroll({
- menu: "page_Tab_title", //要固定的顶部导航栏的ID
- cell: "page_Tab_cell", //分块的选择器ID前缀
- btn: "#page_Tab_buy", //导航栏中控制显隐的按钮选择器
- cell_t: //滚动到时分块距离顶部的距离
- });
- </script>
- <script type="text/javascript" src="http://v2.jiathis.com/code/jia.js" charset="utf-8"></script>
- </body>
- </html>
滚动固定TAB在顶部显示的更多相关文章
- jQuery 顶部导航尾随滚动,固定浮动在顶部
jQuery 顶部导航尾随滚动.固定浮动在顶部 演示 XML/HTML Code <section> <article class="left"> < ...
- 左侧 随着页面滚动固定 fixed. scroll .scrollTop
1.图片. 要求:随着页面滚动 . 左侧应该顶着 浏览器顶部, 向上回滚, 就恢复原状. 2. 代码: html <div class="all "> <!-- ...
- 元素滚动到底部或顶部时阻止body滚动
移动端的弹窗内容有滚动条,滚动到底部或顶部时或影响弹窗下的body滚动,某些浏览器滚动到顶部时不松手就触发了刷新页面的情况,如果不需要这样的默认体验,就需要加一下判断了. var startX,sta ...
- Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页
Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页 在FireMonkey iOS应用程序中的Tab Tab由FMX.TabControl.TTabControl定 ...
- scrollfix.js插件:滚动固定在某个位置
插件文件在/文件 scrollfix.js 用法: var fix = $(".fix"), fixtop = $(".fix-top"), fixStartT ...
- html/css 滚动到元素位置,显示加载动画
每次滚动到元素时,都显示加载动画,如何添加? 元素添加初始参数 以上图中的动画为例,添加俩个左右容器,将内容放置在容器内部. 添加初始数据,默认透明度0.左右分别移动100px. //左侧容器 .it ...
- 可轮播滚动的Tab选项卡
前段时间有试着搭建个后台主题ui框架,有用到可支持滚动的Tab选项卡,模仿着H+后台主题ui框架中的代码造轮子改造了下,可惜代码在公司,不能把代码外发出来(感觉这样被限制了很多,对于这样的公司没办法, ...
- easyUI tab页的显示与隐藏
每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code 隐藏:tab_option = $('#tabid').tabs('getTab'," ...
- IDEA中设置Tab多行显示、打开过多自动关闭的方法
IDEA中默认Tab是单行显示的,而且默认允许同时打开10个Tab,继续打开Tab会根据规则关闭之前打开的Tab.但是可以通过设置来符合自己的使用习惯. 一.打开Tab过多自动关闭 1.选择File→ ...
随机推荐
- js小例子(标签页)
运用js写的一个小例子,实现点击不同的标签出现不同的内容: <!DOCTYPE html> <html> <head> <meta chaset=" ...
- 静态成员函数(面向对象的static关键字)
静态成员函数 与静态数据成员一样,我们也可以创建一个静态成员函数,它为类的全部服务而不是某一个类的具体对象服务.静态成员函数与静态数据成员一样,都是类的内部实现,属于类定义的一部分.普通的成员函数一般 ...
- The Parallel Challenge Ballgame[HDU1101]
The Parallel Challenge Ballgame Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- div+css定位position详解
div+css定位position详解 1.div+css中的定位position 最主要的两个属性:属性 absolute(绝对定位) relative(相对定位),有他们才造就了div+css布局 ...
- SCOI 2013 密码 & 乱搞
题意: Fish 是一条生活在海里的鱼.有一天他很无聊,就到处去寻宝.他找到了位于海底深处的宫殿,但是一扇带有密码锁的大门却阻止了他的前进.通过翻阅古籍,Fish 得知了这个密码的相关信息:1. 该密 ...
- 关于jsp乱码问题的产生原因 及 解决方法。
http://blog.csdn.net/caoxiaohong/article/details/1781777 JSP/JDBC MySQL乱码问题JSP的request 默认为ISO8859_1, ...
- float使内联支持宽高
float使内联元素支持了宽高,可以设置宽高属性:float消除内联元素的空格:
- CentOS6.4 安装OpenResty和Redis 并在Nginx中利用lua简单读取Redis数据
1.下载OpenResty和Redis OpenResty下载地址:wget http://openresty.org/download/ngx_openresty-1.4.3.6.tar.gz Re ...
- NOIp 2014 #2 联合权值 Label:图论 !!!未AC
题目描述 无向连通图G 有n 个点,n - 1 条边.点从1 到n 依次编号,编号为 i 的点的权值为W i ,每条边的长度均为1 .图上两点( u , v ) 的距离定义为u 点到v 点的最短距离. ...
- SDL 五子棋游戏
http://www.jb51.net/article/79271.htm 1.定义窗口大小,棋盘大小 SDL_GetWindowSize()读取窗口大小, 由于棋盘是15*15格局,上下留白一行,在 ...