js页面滚动浮动层智能定位(jQuery)实例页面
来源:互联网 发布:vx软件 编辑:程序博客网 时间:2024/05/16 17:41
HTML代码:
<span class="paren xml-tagangle" style="color: rgb(0, 0, 153);"><</span><span class="keyword xml-tag xml-tag-open" style="color: rgb(0, 0, 255);">div</span> <span class="builtin xml-attribute" style="color: rgb(34, 34, 204);">class</span><span class="undefined"></span><span class="operator" style="color: rgb(0, 119, 119);">=</span><span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>float<span class="after" style="color: rgb(0, 68, 0);">"</span></span> <span class="builtin xml-attribute" style="color: rgb(34, 34, 204);">id</span><span class="undefined"></span><span class="operator" style="color: rgb(0, 119, 119);">=</span><span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>float<span class="after" style="color: rgb(0, 68, 0);">"</span></span><span class="paren xml-tagangle" style="color: rgb(0, 0, 153);">></span> 我是个腼腆羞涩的浮动层...<span class="paren xml-tagangle" style="color: rgb(0, 0, 153);"></</span><span class="keyword xml-tag xml-tag-close" style="color: rgb(0, 0, 255);">div</span><span class="paren xml-tagangle" style="color: rgb(0, 0, 153);">></span>
JS代码:
$.<span class="operand">fn</span>.<span class="operand defun">smartFloat</span> <span class="operator" style="color: rgb(0, 119, 119);">=</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">function</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">var</span> <span class="operand defun">position</span> <span class="operator" style="color: rgb(0, 119, 119);">=</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">function</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand">element</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">var</span> <span class="operand">top</span> <span class="operator" style="color: rgb(0, 119, 119);">=</span> <span class="operand">element</span>.<span class="operand">position</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>.<span class="operand">top</span><span class="comma">,</span> <span class="operand">pos</span> <span class="operator" style="color: rgb(0, 119, 119);">=</span> <span class="operand">element</span>.<span class="operand">css</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>position<span class="after" style="color: rgb(0, 68, 0);">"</span></span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; $<span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand builtin" style="color: rgb(34, 34, 204);">window</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>.<span class="operand">scroll</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand keyword" style="color: rgb(0, 0, 255);">function</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">var</span> <span class="operand">scrolls</span> <span class="operator" style="color: rgb(0, 119, 119);">=</span> $<span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand keyword" style="color: rgb(0, 0, 255);">this</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>.<span class="operand">scrollTop</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="operand keyword" style="color: rgb(0, 0, 255);">if</span> <span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand">scrolls</span> <span class="operator" style="color: rgb(0, 119, 119);">></span> <span class="operand">top</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">if</span> <span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand builtin" style="color: rgb(34, 34, 204);">window</span>.<span class="operand">XMLHttpRequest</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand">element</span>.<span class="operand">css</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand hashkey" style="color: rgb(170, 85, 17);">position</span><span class="hasharrow" style="color: rgb(255, 0, 0);">:</span> <span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>fixed<span class="after" style="color: rgb(0, 68, 0);">"</span></span><span class="comma">,</span> <span class="operand hashkey" style="color: rgb(170, 85, 17);">top</span><span class="hasharrow" style="color: rgb(255, 0, 0);">:</span> <span class="operand">0</span> <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="paren" style="color: rgb(0, 0, 153);">}</span> <span class="operand keyword" style="color: rgb(0, 0, 255);">else</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand">element</span>.<span class="operand">css</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand hashkey" style="color: rgb(170, 85, 17);">top</span><span class="hasharrow" style="color: rgb(255, 0, 0);">:</span> <span class="operand">scrolls</span> <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="paren" style="color: rgb(0, 0, 153);">}</span> <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="operand keyword" style="color: rgb(0, 0, 255);">else</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand">element</span>.<span class="operand">css</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand hashkey" style="color: rgb(170, 85, 17);">position</span><span class="hasharrow" style="color: rgb(255, 0, 0);">:</span> <span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>absolute<span class="after" style="color: rgb(0, 68, 0);">"</span></span><span class="comma">,</span> <span class="operand hashkey" style="color: rgb(170, 85, 17);">top</span><span class="hasharrow" style="color: rgb(255, 0, 0);">:</span> <span class="operand">top</span> <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="paren" style="color: rgb(0, 0, 153);">}</span> <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="paren" style="color: rgb(0, 0, 153);">}</span>; <span class="operand keyword" style="color: rgb(0, 0, 255);">return</span> $<span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand keyword" style="color: rgb(0, 0, 255);">this</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>.<span class="operand">each</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand keyword" style="color: rgb(0, 0, 255);">function</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span> <span class="paren" style="color: rgb(0, 0, 153);">{</span> <span class="operand">position</span><span class="paren" style="color: rgb(0, 0, 153);">(</span>$<span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="operand keyword" style="color: rgb(0, 0, 255);">this</span><span class="paren" style="color: rgb(0, 0, 153);">)</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>; <span class="paren" style="color: rgb(0, 0, 153);">}</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>;<span class="paren" style="color: rgb(0, 0, 153);">}</span>;<span class="comment comment-line" style="color: rgb(153, 153, 153);"><span class="before" style="color: rgb(187, 170, 170);">//</span>绑定</span>$<span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="string" style="color: rgb(34, 136, 34);"><span class="before" style="color: rgb(0, 68, 0);">"</span>#float<span class="after" style="color: rgb(0, 68, 0);">"</span></span><span class="paren" style="color: rgb(0, 0, 153);">)</span>.<span class="operand">smartFloat</span><span class="paren" style="color: rgb(0, 0, 153);">(</span><span class="paren" style="color: rgb(0, 0, 153);">)</span>
0 0
- js页面滚动浮动层智能定位(jQuery)实例页面
- js页面滚动浮动层智能定位(jQuery)实现
- JQuery页面滚动浮动层智能定位
- jQuery实现页面滚动时层智能浮动定位
- jQuery实现页面滚动时层智能浮动定位
- 页面滚动时层智能浮动定位,jQuery/MooTools实现
- jQuery实现页面滚动时层智能浮动定位
- js页面滚动时层智能浮动定位实现
- js页面滚动时层智能浮动定位实现(jQuery/MooTools)
- jQuery浮动层跟随页面滚动
- js实现滚动时层智能浮动定位
- jQuery实现浮动层跟随页面滚动效果
- jQuery实现页面滚动时元素的智能定位
- jquery js 页面元素定位
- jQuery实现页面元素智能定位
- 简单页面 浮动层
- jquery浮动定位层导航描点上下滚动的浮动导航
- JQuery实现的页面滚动时浮动窗口控件
- javascript中bind()函数实现和应用以及多次bind的结果和参数位置的思考
- 手动为sublime text3添加package control插件
- ./configure -build,-host,-target设置
- 面试再谈struct和union大小问题
- 第3周项目4 顺序表应用问题(1)
- js页面滚动浮动层智能定位(jQuery)实例页面
- 第4周 项目3-单链表应用
- Servlet 3.0 新特性详解
- UITableViewCell中设置不同图片尺寸相同以及设置图片为圆形的方法
- 工作方法总结
- How can I get file extensions with JavaScript?
- 完整java开发中JDBC连接数据库代码和步骤
- SecureCRT 7.2.0 Mac版密码无法保存的解决办法(转载)
- [深入理解Java虚拟机]第三章 垃圾收集算法