MozTW 討論區 https://forum.moztw.org/ |
|
高手請進: 取得Firefox browser的滾軸寬度 https://forum.moztw.org/viewtopic.php?f=13&t=24767 |
第 1 頁 (共 1 頁) |
發表人: | maomao_mc [ 2008-10-18, 16:21 ] |
文章主題 : | 高手請進: 取得Firefox browser的滾軸寬度 |
取得Firefox browser的滾軸寬度 Calculating The Browser Scrollbar Width 如何取得scrollbarWidth()後,將它變成為負數(e.g -20px)套用在css/html,令到Firefox滾軸(scrollbar)寬度向右邊少-20px出現,達致與ie6一樣,2個上下frames中的table置中。 body {margin-right: -20px !important; margin-right: 0px} <script language="JavaScript" type="text/javascript"> function scrollbarWidth() { var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>'); // Append our div, do our calculation and then remove it $('body').append(div); var w1 = $('div', div).innerWidth(); div.css('overflow-y', 'scroll'); var w2 = $('div', div).innerWidth(); $(div).remove(); return (w1 - w2); }; </script> 詳細來源:Calculating The Browser Scrollbar Width http://jdsharp.us/jQuery/minute/calcula ... -width.php viewtopic.php?t=24704 |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |