首页 新闻 会员 周边

JS实现一个DIV在指定区域内浮动定位

0
悬赏园豆:5 [已解决问题] 解决于 2012-07-16 10:48

最近在做一个JS效果,要求实现新闻页右侧有一块区域,当鼠标滚轮向下滚的时候,那块区域也向下浮动。就是跟着用户的视觉范围移动。可是这一块范围是必须指定的,不知道该怎么做,求大侠们指点。

路过春秋的主页 路过春秋 | 初学一级 | 园豆:10
提问于:2012-07-12 12:12
< >
分享
最佳答案
0
(function () {
    var resizeContentWrapper = function () {
            console.group('resizing');


            var target = {
                content: $('#resizeme')
            };

            //resize target content to window size, assuming that last time around it was set to document height, and might be pushing document height beyond window after resize
        //TODO: for performance, insert flags to only do this if the window is shrinking, and the div has already been resized
            target.content.css('height', $(window).height());

            var height = {
                document: $(document).height(),
                window: $(window).height()
            };

            console.log('height: ', height);


            if (height.document > height.window) {
                // Scrolling needed, no need to externd the sidebar
                target.content.css('height', '');

                console.info('custom height removed');
            } else {
                // Set the new content height
                height['content'] = height.window;
                target.content.css('height', height['content']);

                console.log('new height: ', height);
            }
            console.groupEnd();
        }
    resizeContentWrapper();
    $(window).bind('resize orientationchange', resizeContentWrapper);
})(jQuery);

http://stackoverflow.com/questions/7785691/using-javascript-to-resize-a-div-to-screen-height-causes-flickering-when-shrinki

收获园豆:5
悟行 | 专家六级 |园豆:12559 | 2012-07-12 14:04

大牛,你太厉害了,就是这个方法,嘿嘿,终于解决了,心情很开心。

路过春秋 | 园豆:10 (初学一级) | 2012-07-16 10:48
其他回答(1)
-1

监视:新闻页右侧有一块区域 这个DIV 的鼠标事件???

阿K&LiveCai | 园豆:514 (小虾三级) | 2012-07-12 18:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册