JS中的style.marginTop不能使用负值

时间:2018-03-29 05:32:15

标签: javascript html css

因此,我尝试在window.pageYOffset事件的页面上为某个容器添加当前marginTop值作为onclick值。但它不会发生。

我还想承认,将window.pageYOffset的正值添加到marginTop没有问题。

这是我的代码:

    let a = window.pageYOffset;

    const rightColumn = document.querySelector('.right-side__column');
    rightColumn.style.marginTop = '-' + a + 'px'; // in such way a in 
                                           // padding even equal to 0.

    // rightColumn.style.marginTop = a + 'px'; - work fine, the value is transfer normally.

1 个答案:

答案 0 :(得分:0)

请尝试使用 Flux<StandardEntity> results = Flux.from( mongoCollectionManager.getCollection(channel) .find( and(gte("lastUpdated", begin), lte("lastUpdated", end)))) .map(d -> new StandardEntity(d.getString("price"), d.getString("lastUpdated"))); Long lastIndex = results .count() .block(); final double standardPage = 10.0D; final double step = lastIndex / standardPage; final double[] counter = {0.0D}; return results .take(1) .mergeWith( results .skip(1) .filter(e -> { if (lastIndex > standardPage) if (counter[0] >= step) { counter[0] = counter[0] - step + 1; return true; } else { counter[0] = counter[0] + 1; return false; } else return true; }));

,而不是您所做的