scrolltop

鼠标滚到一定高度分页

可紊 提交于 2019-11-27 23:58:52
主页面,就是一个分页的操作 public ActionResult Index(string typename = "", int page=1) { var paging = new Paging(); paging.PageIndex = page; paging.PageSize = 10; NewsContentInfo news = new NewsContentInfo(); var list = conbll.NewsList(news, ref paging); //ViewData["PingYin"] = typename;//点击连接时的样式变化 ViewBag.PageCount = paging.PageCount;//总页数,在页面上写个隐藏的文本框显示总页数,因为js需要用到 return View(list); } /// 部分视图 public ActionResult NewsList(int page = 1) { var paging = new Paging(); paging.PageIndex = page; paging.PageSize = 10; NewsContentInfo news = new NewsContentInfo(); var list = conbll.NewsList(news, ref paging);

vue获取滚动的scrollTop的值

北慕城南 提交于 2019-11-27 21:29:30
mounted() { // let _this=this window.addEventListener('scroll', () => { let top = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset console.log(top); if (top > 700) { this.scrollTag = true; } else { this.scrollTag = false } }) } 来源: https://blog.csdn.net/qq_42074075/article/details/99736565

监听页面滚动及滚动到指定位置

走远了吗. 提交于 2019-11-27 21:23:43
两种监听页面滚动的方法 一、原生js通过window.onscroll监听 window.onscroll = function() { //为了保证兼容性,这里取两个值,哪个有值取哪一个 //scrollTop就是触发滚轮事件时滚轮的高度 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; console.log("滚动距离" + scrollTop); } 二、Jquery通过$(window).scroll()监听 $(window).scroll(function() { //为了保证兼容性,这里取两个值,哪个有值取哪一个 //scrollTop就是触发滚轮事件时滚轮的高度 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; console.log("滚动距离" + scrollTop); }) 将页面滚动到指定位置 主要使用的是锚点技术,锚点元素通过scrollTop值改变进行定位。 锚点 锚点是网页制作中超级链接的一种,又叫命名锚记。命名锚记像一个迅速定位器一样,是一种页面内的超级链接。 法一 直接使用scrollTop 使用scrollTop方法

How to get maximum document scrolltop value

China☆狼群 提交于 2019-11-27 16:01:42
问题 I am making some plugin and I need to get maximum scrollTop value of the document. Maximum scrollTop value is 2001 , but $(document).height() returns 2668 and $('body')[0].scrollHeight gives me undefined . How to get 2001 through javascript/jquery?! 回答1: The code in your comments should work: $(document).height() - $(window).height() Here's an example that alerts when you scroll to the maximum scroll position: http://jsfiddle.net/DWn7Z/ 回答2: If you want to "guess" the maximum scrolltop value,

scrollTop() returns 0 in Firefox, but not in Chrome

北城以北 提交于 2019-11-27 15:46:21
问题 Not sure if there's another question regarding this, if so I apologize and please don't release the hounds. Using the html5 doctype and doing a quick console.log off my scroll listener that tells me the value of scrollTop() value. I'm basically doing this so when I scroll past a point, I change the opacity of an element. I'm doing this using an MVS solution and I don't have the ability to push this to an external site so you can look. Here's a quick snippet: var opacity = 1; var scrollTop = $

Can't get scrollTop() to work in both Chrome & Firefox

流过昼夜 提交于 2019-11-27 15:44:48
问题 I am having trouble getting the scrollTop() method to work in both Firefox and Chrome. I used $('body, html').scrollTop(); however, it doesn't work in Chrome. Only $('body').scrollTop(); works in Chrome. Any thoughts would be greatly appreciated. Below is my code. <!DOCTYPE html> <html> <head> <title>Demo</title> <style type="text/css"> body { height: 2000px; } #light { display: block; position: fixed; top: 50%; left: 50%; margin-left: -400px; margin-top: -200px; width: 800px; height: 400px;

The same old issue, .scrollTop(0) not working in Chrome & Safari

梦想与她 提交于 2019-11-27 15:12:38
First, let me point out, i've googled and even looked at answers on here like this and this , however, I'm still yet to find a working solution for my case. I've designed a page that has several fixed elements covering the page and makes of html5/css3 to create a clean "mask" over the main document, thus allowing the body scroll bar to still scroll the underlying content. In firefox and ie (bleh), scrollTop(0) is working perfect. However, as stated by the question, not so much in my fav browsers. Something I've made note of is to call the following both before the scrollTo event and after $(

Call Scroll only when user scrolls, not when animate()

℡╲_俬逩灬. 提交于 2019-11-27 14:53:25
I have a few links across the page with the purpose of "going to the top", accomplished by scrolling the page to the top with a nice animation. I've noticed that sometimes while the page is scrolling the user will want to scroll back down, for example, but this is not possible. The screen will only stutter but will continue animating until it reaches the top. I want to stop the animation if the user attempts to scroll, therefore I wrote this code: $('#gototop').click(function() { $('body').animate({scrollTop:0},3000); $(window).scroll(function () { $('body').stop(); }); return false; }) This

Why is body.scrollTop deprecated?

二次信任 提交于 2019-11-27 14:17:02
It seems body.scrollTop (and body.scrollLeft ) are deprecated in ES5 strict-mode. What is the reason for this, given that it still seems okay to use these properties on other DOMElement s? Background Info: I have a function that tries to increase (or decrease, as specified) the scrollTop values of all the ancestors of an element , till one of these actually changes. I am wondering if, to stay complaint with strict-mode, I should specifically check against the body element as the chain of parents moves upward. [Obviously, body refers to document.body ] It's Chrome's own incorrect behavior that

页面中的‘返回顶部’(位置固定,指定位置显示/隐藏) Lebal:博客园美化

此生再无相见时 提交于 2019-11-27 13:10:50
在页面中经常需要使用到返回顶部按钮,如果页面内容过多过长,手动滑动滚动条比较麻烦,所以一般会出现返回顶部按钮,一键回到顶部。本文实现的返回顶部的效果,将按钮在滚动条指定高度出现,并固定的页面指定位置。显示为一张图片,鼠标放上显示的是返回顶部文字提示。实现过程如下: 在html文件中: <div id="return-top" class="top_e"> <img src="/static/img/totop.png" width="60" id="img" > <div style="width:60px;margin:auto;"> <p id='font' style="font-size:20px;margin-left:10px;display:none;">返回<br>顶部</p> </div> </div> 这里外面的div作为返回顶部的外层。 内部有两部分: 第一部分是一张图片,从阿里矢量图片库中下载好的矢量图片,如图: 当然也可以根据自己的需要,选择其他样式和颜色。 第二部分是’返回顶部‘四个字,这里需要换行,所以加了标签。 css样式代码 .top_e{ position:fixed;right:10px;bottom:40px; background:rgba(204,200,255,0.6); border-radius:15px; cursor