[英]How to set position with css method in jquery?
我的.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'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.