1.JS代码: onload = function () { //初始化 scrollToLocation(); }; function scrollToLocation() { var mainContainer = $('#thisMainPanel'), scrollToContainer = mainContainer.find('.son-panel:last');//滚动到<div id="thisMainPanel">中类名为son-panel的最后一个div…
相对浏览器,将指定div滚到到指定位置,其用法如下: $("html,body").animate({scrollTop: $(obj).offset().top},speed); ps:obj是需要定位的对象,speed是滚动的速度 然而如果需要相对某一个容器(称之div1),将其内部的div2滚动到相对div1的指定位置,用法如下: $("div1").animate({scrollTop: $("div2").position().top}…
代码如下(主要是通过设置Location的hash属性): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <…
这里有一个方法可以将DIV的滚动条滚动到其子元素所在的位置,方便自动定位. var container = $('div'), inner = $('#inner'); container.scrollTop( inner.offset().top - container.offset().top + container.scrollTop() ); // Or you can animate the scrolling: container.animate({ scrollTop: inner…
相对浏览器,将指定div滚到到指定位置,其用法如下 $("html,body").animate({scrollTop: $(obj).offset().top},speed); ps:obj是需要定位的对象,speed是滚动的速度 然而需要相对某一个容器(称之div1),将其内部的div2滚动到相对div1的指定位置,用法如下: $("div1").animate({scrollTop: $("div2").position().top},sp…
<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function(){ $(".btn1").click(function(){ $("div").…
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> .redMark{ color: red; font-weight: bold; } .blueMark{ color: blue; font-weight: bold; } </style> <script src=…
HTML: <div class="top"> ·····内容 </div> <div class="scroll"></div> <div class="bottom"> ·······内容 </div> CSS: .sfixed{ position:fixed; top:0px; left:0px; ; } .scroll{ ······样式 } Jq: <scri…
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jquery div随滚动条滚动效果</title> <script src="../js/jquery-1.11.1.min.js" type="text/javascript"></script> <script type="text/jav…
有段时间没有碰Web端了,最近做了个功能,需要做个DIV随滚动条滚动而滚动,mark一下: 源码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"&g…