鍍金池/ 問答/Linux  HTML/ css、原生js滾動效果

css、原生js滾動效果

const footerContentContainer = this.refs.footerContentContainer,
              howContainer = this.refs.howContainer;
        const footerContentContainerHeight = footerContentContainer.scrollHeight;
        const howContainerPositionTop = howContainer.offsetTop;

        footerContentContainer.style.height = this.state.isActive ? 0 : footerContentContainerHeight;
        if(!this.state.isActive && howContainerPositionTop > 0) document.body.scrollTop = howContainerPositionTop;

當前要實現(xiàn)一個效果,一開始footerContentContainer height為0,置為不為0之后,body的scrollTop也跟著變化,當前body的scrollTop變化時很生硬,我應該加上footerContentContainer 的css樣式里面加上 transition: height 0.5s。但是有了過渡效果,howContainerPositionTop 獲取的值偶爾不一樣。

我改如何去修改這個過渡效果

回答
編輯回答
艷骨

加個倒計時,逐一遞減

2017年4月21日 23:08