JQuery計算捲軸長度與位置,程式碼如下: javascript 複製程式碼 程式碼如下: <br> var scrMinHeight = 1; //滚动条最小高度<br> var scrMaxHeight = 0; //滚动条最大高度<br> var scrDefualtTop = 80; //滚动条默认位置<br> var scrHeight = 0;<br> //初始化滚动条<br> function InitScroll() {<br> scrMaxHeight = $("#mainScrollContent").height(); //文本框高度<br> scrHeight = document.getElementById("mainScrollContent").scrollHeight; //滚动文本高度<br> scrHeight = parseInt((scrMaxHeight / scrHeight) * scrMaxHeight);<br> if (scrHeight <= scrMinHeight) { scrHeight = scrMinHeight; }<BR> if (scrHeight >= scrMaxHeight) { $("#scrollContent").hide(); }<br> else {<br> $("#scrollContent").show();<br> $("#scrollContent .tiao_mid").css("height", (scrHeight - 19) + "px");<br> }<br> } <p> $(document).ready(function () {<br> $(".bod").height(($(document).height() - 80) + "px");<br> $("#mainScrollContent").height(($(document).height() - 125) + "px");<br> scrMaxHeight = ($(document).height() - 125); //滚动条最大高度<br> $("#scrollBody").height(($(document).height() - 125) + "px");<br> $("#scrollBodyBack").height(($(document).height() - 125) + "px");</p> <p> InitScroll();<br> $("#mainScrollContent").scroll(function () {<br> ChangeScroll();<br> });<br> var y1 = 0;<br> $("#scrollContent").mousedown(function (event) {<br> var scrContentTop = $("#scrollContent").css("top");<br> y1 = event.clientY - parseInt(scrContentTop.replace("px", ""));<br> $("#scrollContent").mousemove(function (event) {<br> if ((event.clientY - y1) < scrDefualtTop) {<BR> $("#scrollContent").css("top", scrDefualtTop + "px");<BR> }<BR> else if ((event.clientY - y1) > (scrDefualtTop + scrMaxHeight - scrHeight)) {<br> $("#scrollContent").css("top", (scrDefualtTop + scrMaxHeight - scrHeight) + "px");<br> }<br> else {<br> $("#scrollContent").css("top", (event.clientY - y1) + "px");<br> }<br> ChangeScrollContent();<br> });<br> }).mouseup(function () {<br> $("#scrollContent").unbind("mousemove");<br> }).mouseout(function () {<br> $("#scrollContent").unbind("mousemove");<br> });<br> });</p> <p> //改變滾動內容位置<br> function ChangeScrollContent() {<br> var scrTop = $(" replace( "px", ""));<br> st = ((st - scrDefualtTop) * document.getElementById("mainScrollContent").scrollHeight)/ //滾動的高度<br> }<br> <br> //改變捲軸位置</p> function ChangeScroll() {<p> var scrTop = $("#mainScrollContent").scrollTop(op); scrMaxHeight) / document.getElementById("mainScrollContent").scrollHeight scrDefualtTop;<br> $("#scrollContent").css("top", scrTop "ppx");<scrollcontent scrtop><br> <br>捲動區域內容DIV:<br>html<br><br></scrollcontent></p> </div> <p>複製程式碼<br><br></p> <div class="codetitle"> 程式碼如下:<span><div class="codebody" id="code71578"> <br><div class="jtc_neir" id="Div1" style="height: 100px;"> <br> 營業總收入:11.66億元(年成長-1.75%)<br> ><br> <a href="bank.aspx">dddd</a>淨利潤:0.19億元(年成長23.72%)<br> <br><br> 每股盈餘:0.04元<br> <br><br> 淨值報酬率:1.58%<br> <br><br> 毛利率:12.22%(年成長39.89%)元(年成長-7.14%)<br><br> as大蘇打撒旦撒<br> <br><br> 阿斯蒂芬多個地方營業總收入:11.66億元(年成長-1.75%)<br> <br><br> 淨利:0.19億元(年成長23.72%)<br> <br><br> 比率:1.58%<br> <br><br> 毛利率:12.22%(年成長39.89%)<br> <br><br> /><br> as大蘇打撒旦撒<br> <br><br> 史蒂芬多地方營業總收入:11.66億元(同比增長-1.75%) <br><br> 每股盈餘:0.04元<br> <br><br> ><br> 毛利率:12.22%(年成長39.89%)<br> <br><br> 總資產:30.46億元(同比成長-7.14%)<br> <br><br> 阿斯蒂芬多地方營業總收入:11.66億元(年成長-1.75%)<br> <br><br> )<br> <br><br> 每股盈餘:0.04元<br> <br><br> 淨值報酬比去年同期成長39.89%)<br> <br><br> 總資產:30.46億元(年成長-7.14%)<br><br> as大蘇打>阿斯蒂芬多地方營業總收入:11.66億元(年成長-1.75%)<br> <br><br> 淨利:0.19億元(年成長23.72%)<br> . > 每股盈餘:0.04元<br> <br><br> 淨值報酬率:1.58%<br> <br><br> /><br> 總資產:30.46億元(同比增長-7.14%)<br><br> as大蘇打撒旦撒<br> <br><br>1<br> 🎜><div class="jtc_tiao" style="background-color: rgb(196,206,208); z-index: 2;" id="Div2"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"><br></div> <br><div class="jtc_tiao"> id="Div3"><br> </div> <br><div class="jtc_tiao" id="Div4"> <br> <div class="tiao_up"> <br> </div> <br> <div class="tiao_mid"> <br> tiao_bottom"><br> </div> <br> </div> <br><br> </div> 主要樣式:<p>css<br><br></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="49551" class="copybut" id="copybut49551" onclick="doCopy('code49551')">複製程式碼<u></u></a> 程式碼如下:</span><div class="codebody" id="code49551"> <br>.jtc_neir{margin-left:20px;右邊距:20px;顏色:#000000;字體大小:12px;背景:無;行高:32px;溢出-y:溢出;溢出-x:隱藏滾動滾動; <br> 捲軸-3dlight-color:rgb(222,222,222); <br> 捲軸條箭頭顏色:rgb(222,222,22225)> ,222); <br> 捲軸-darkshadow-color :rgb(222,222,222); <br> 滾動條面顏色:rgb(222,222,222); <br> 滾動條突出顯示顏色:rgb(222,22,22225); 22,222);} <br> <br>.jtc_tiao{width:8px;位置:絕對;上:80px;右:20px; z-index:10;} <br>.tiao_up{寬度:8px;高度:10px;背景:url(../ images/scrollbar-3.jpg) 左上無重複;行高:0px;溢出:隱藏;} <br>.tiao_mid{寬度:8px;背景:url(../images/scrollbar-3.jpg) -39px 中心重複-y;行高:0px;溢出:隱藏;} <br>.tiao_bottom{寬度:8px;高度:10px;背景:url(../images/scrollbar-3.jpg)-13px底部無重複;字體大小:0;行高:0px;溢位:隱藏;} <br><br><br> </div> </div> </div></span> </div>