jq+div 부동

1111 단어
1. jq 플러그인
$.fn.smartFloat = function() {
			    var position = function(element) {
			        var top = element.position().top, pos = element.css("position");
			        $(window).scroll(function() {
			            var scrolls = $(this).scrollTop();
			            if (scrolls > top) {
			                if (window.XMLHttpRequest) {
			                    element.css({
			                        position: "fixed",
			                        top: 0
			                    });    
			                } else {
			                    element.css({
			                        top: scrolls
			                    });    
			                }
			            }else {
			                element.css({
			                    position: "absolute",
			                    top: top
			                });    
			            }
			        });
			    };
			    return $(this).each(function() {
			        position($(this));                         
			    });
			};

2. 플러그인 diaoyong
$(function(){
				$(".aside div").smartFloat();
			})

좋은 웹페이지 즐겨찾기