我的 .csw-step4-price-summary
div的默认值是
.csw-step4-price-summary {
width: 270px;
position: absolute;
display: inline-block;
bottom: 661px;
right: 40px;
}
当我想执行以下操作时,它确实会将位置更改为固定,但对底部和正确的值没有反应。
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 220) {
$(".csw-step4-price-summary").css({
'position': 'fixed',
'bottom': '661',
'right': '140'
});
} else {
$(".csw-step4-price-summary").css({ 'position': 'absolute'});
}
}(;
有什么建议为什么会发生这种情况?预先感谢。
尝试在CSS函数中的单元中使用'px'
$(".csw-step4-price-summary").css({
'position': 'fixed',
'bottom': '661px',
'right': '140px'
});
它是
'bottom': '661px',
'right': '140px'