滚动后的Div(不是位置:固定)

编程入门 行业动态 更新时间:2024-10-28 14:35:58
本文介绍了滚动后的Div(不是位置:固定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我发现它在某个时候之前,现在我不能。我想在苹果商店找到类似购物车的东西,它的div不是绝对的,也不是固定的,例如,我们说它在屏幕的中心,只有当你向下滚动它,滚动只到不消失,当它到达浏览器头部的边框...

我不知道如果我清楚。我已经搜索,但我发现的是css位置固定的东西。

你能帮我一个链接或什么吗?

最好的问候

解决方案

应用商店使用以下css:

div.cto div.slider-content { height:100%; overflow:visible; padding-bottom:20px; position:absolute; 右:0; top:-10px; width:169px; } div.cto div.pinned_top div#secondary { position:absolute; top:0; right:0; } div.cto div.floating div#secondary { position:fixed; top:0; }

使用javascript,div的类从'pinned_top'

  • 要确定滚动像素的数量: $('html')。scrollTop()
  • 要监听滚动事件:api.jquery/scroll/

I found it sometime ago and now I can't. I want to find something like the shopping cart at the apple store, it's a div thats not positioned absolute nor fixed, for instance, let's say it's at the center of the screen, and only when you scroll down it follows the scroll only to not disappear, when it reaches the border of the browser header...

I'm not sure If i'm being clear. I've searched but all I found is the css position fixed stuff.

Can you help me with a link or something?

Best Regards

解决方案

The app store uses the following css:

div.cto div.slider-content { height: 100%; overflow: visible; padding-bottom: 20px; position: absolute; right: 0; top: -10px; width: 169px; } div.cto div.pinned_top div#secondary { position:absolute;top:0;right:0; } div.cto div.floating div#secondary { position:fixed;top:0; }

Using javascript, the class of the div is changed from 'pinned_top' to 'floating' when you scroll down.

About the javascript:

  • To determine the number of pixels scrolled: $('html').scrollTop()
  • To listen to scroll events: api.jquery/scroll/

更多推荐

滚动后的Div(不是位置:固定)

本文发布于:2023-10-08 03:14:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471347.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   Div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!