滾動條定位

2021-06-26 23:49:09 字數 1241 閱讀 4692

首先來乙個例子:

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.

this is some text. this is some text. this is some text. this is some text. this is some text. this is some text.  

把 scroll top offset 設定為 100px

獲得 scroll top offset

注:滾動條所在的div必須有overflow屬性且value不能為hidden

請看複雜情況:

這種情況主要用於使用了滾動條外掛程式的情況,一眼看去不知道那個div在滾動,隨意找乙個div是不能正常工作的。

如果想加入一點動畫效果,可以適應animate方法

var scrolltop = 100;

$(".form").parent().parent().animate("scrolltop: "+ scrolltop +"'px'", 400);

從form向上找兩個parent就是帶有overflow屬性的滾動條所在的容器

Div滾動條定位設定

1.div 資料 2.通過js去設定div滾動條的位置 document.getelementbyid datadiv scrolltop div滾動條的垂直位置設定屬性 document.getelementbyid datadiv scrollleft div滾動條的水平位置設定屬性3.通過js...

CSS定位和滾動條

position absolute 絕對定位 1 定位屬性值 absolute 2 在頁面中不再佔位 浮起來了 就無法繼承父級的寬度 必須自己自定義寬度 3 一旦定位後,定位的布局方位 top bottom left right都能參與布局 4 絕對定位的參考係是最近的定位父級 不是父級中的哪一點,...

vb 垂直滾動條定位

sub treefill3 ctime as string,byval ckey as string tree3.nodes.clear 迴圈填充tree1控制項內容 dim c as string dim cnode as node dim csql as string dim crec as r...