滚动到顶部固定

 1     // 滚动到顶部固定
 2     var navH = $(".fixedTop").offset().top;
 3     $(".fixedTop").wrap("<div class=‘background-fixed‘></div>");
 4     $(‘.flowDev‘).scroll(function () {
 5         var scroH = $(‘.flowDev‘).scrollTop();
 6         if (scroH >= navH) {
 7             $(".fixedTop").css({"position": "fixed", "top": 0});
 8             $(".fixedTop").css({"z-index": "999"});
 9             $(".fixedTop").css({"background": "#f4f4f4"});
10             $(".fixedTop").css({"width": "94%"});
11         } else if (scroH < navH) {
12             $(".fixedTop").css({"position": "static"});
13             $(".fixedTop").css({"background": "#fff"});
14             $(".fixedTop").css({"width": "100%"});
15         }
16     });

原文地址:https://www.cnblogs.com/yangguoe/p/9267397.html

时间: 2024-08-30 13:16:38

滚动到顶部固定的相关文章

菜单滚动至顶部后固定

<!DOCTYPE HTML><html><head><meta charset="UTF-8"><title>菜单滚动至顶部后固定-柯乐义</title><style type="text/css">.wrapper{width:1000px;height:2000px;margin-left:auto;margin-right:auto;}.header{height:150px

JS 实现DIV 滚动至顶部后固定

<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>DIV滚动至顶部后固定</title> </head> <body style="height:2000px;"> <div style="height: 200px"></div> <div id=&q

jquery实现平滑滚动到顶部、底部、或者指定位置(个人随笔)

个人随笔,欢迎指教. 代码如下: <!doctype html> <html> <head> <meta charset="utf-8"> <title>jquery实现平滑滚动到顶部.底部.或者指定地方</title> <script type="text/javascript" src="JavaScript/jquery-1.11.2.min.js"><

div随页面滚动遇顶固定的两种方法(js&amp;jQuery)

一.遇顶固定的例子 我一直以为是某个div或层随屏幕滚动,遇顶则固定,离开浏览器顶部又还原这样的例子其实不少,其实它的名字叫"层的智能浮动效果".目前我们在国内的商业网站上就常常看到这样的效果了.例如淘宝网的搜索结果页的排序水平条,在默认状态时,该工具条是跟随页面滚动的,如下图: 而当我们下拉滚动条,随着页面向下滚动,当此工具条接触到浏览器的上边缘时,这时就会独立出来固定在顶部,不跟随页面滚动而滚动了,如下图: 类似的例子效果我们在别的网站上都有看到过,例如腾讯微博首页上,当我们下拉屏

Android ScrollView 滚动到顶部

有时候使用ScrollView,里边控件比较多的时候,打开界面,会滑到底部,如果要设置滑动到顶部,一般有两种方法 1.使用fullScrol(),scrollView.fullScroll(ScrollView.FOCUS_DOWN);滚动到底部 scrollView.fullScroll(ScrollView.FOCUS_UP);滚动到顶部 需要注意的是,该方法不能直接被调用 因为Android很多函数都是基于消息队列来同步,所以需要一部操作, addView完之后,不等于马上就会显示,而是在

jQuery 随滚动条滚动效果 (固定版)

//侧栏随动 var rollStart = $('.feed-mail'), //滚动到此区块的时候开始随动 rollSet = $('.search,.weibo,.group,.feed-mail,.tags'); //添加rollStart之前的随动区块 rollStart.before('<div class="da_rollbox" style="position:fixed;background-color:#fff;width:inherit;"

Windows Phone 8.1开发:如何让ListView滚动到顶部,回到第一条?

Windows Phone 8.1开发中,ListView向下滑动了半天,用户如果突然想回头看看第一条数据怎么办? 如何让listView滚动到顶部,回到第一条? 很简单,一行代码.调用ListView的ScrollIntoView()方法就好~ listView1.ScrollIntoView(listView1.Items.First());

[jquery]判断页面滚动到顶部和底部(适用于手机web加载)

//判断页面滚动到顶部和底部 $(window).scroll(function(){ var doc_height = $(document).height(); var scroll_top = $(document).scrollTop(); var window_height = $(window).height(); if(scroll_top == 0){ alert("到顶啦"); }else if(scroll_top + window_height >= doc

基于jQuery实现页面滚动时顶部导航显示隐藏效果

<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> <link rel=&quo