В прилагаемом jQuery есть метод «setFixed()», который устанавливает положение как position = 'fixed'; изменить его в положение = «относительно»
Реальная функция
function setFixed() {
// Only fix the target element and the spacer if we need to.
if (!isFixed()) {
// Set the spacer to fill the height and width of the target
// element, then display it.
spacer.css({
'display' : target.css('display'),
'width' : target.outerWidth(true),
'height' : target.outerHeight(true),
'float' : target.css('float')
});
// Set the target element to fixed and set its width so it does
// not fill the rest of the page horizontally. Also, set its top
// to the margin top specified in the options.
cssOptions={
'z-index' : base.options.zIndex,
'position' : 'relative',
'top' : base.options.bottom == -1?getMarginTop():'',
'bottom' : base.options.bottom == -1?'':base.options.bottom,
'margin-left' : '0px'
}
if (!base.options.dontSetWidth){ cssOptions['width']=target.css('width'); };
target.css(cssOptions);
target.addClass(base.options.baseClassName);
if (base.options.className) {
target.addClass(base.options.className);
}
position = 'fixed';
}
}
Изменения в
function setFixed() {
// Only fix the target element and the spacer if we need to.
if (!isFixed()) {
// Set the spacer to fill the height and width of the target
// element, then display it.
spacer.css({
'display' : target.css('display'),
'width' : target.outerWidth(true),
'height' : target.outerHeight(true),
'float' : target.css('float')
});
// Set the target element to fixed and set its width so it does
// not fill the rest of the page horizontally. Also, set its top
// to the margin top specified in the options.
cssOptions={
'z-index' : base.options.zIndex,
'position' : 'relative',
'top' : base.options.bottom == -1?getMarginTop():'',
'bottom' : base.options.bottom == -1?'':base.options.bottom,
'margin-left' : '0px'
}
if (!base.options.dontSetWidth){ cssOptions['width']=target.css('width'); };
target.css(cssOptions);
target.addClass(base.options.baseClassName);
if (base.options.className) {
target.addClass(base.options.className);
}
position = 'relative';
}
}
Это всегда хорошая идея, чтобы скопировать соответствующий код на вопрос. Прямо сейчас, если ваше перо кода удалено, никто другой не сможет воспользоваться этим вопросом. К счастью, @mateen предоставил код в одном из своих ответов, но это действительно должно быть частью вопроса. –