CSS3頁面切換動畫效果


 

用的react開發頁面,頁面切換的時候太快了,感覺效果不是很好,網上搜索了很多,發現這個簡單方便,效果也還可以,記錄一下

在父組件上添加 className=‘animate-route’


class Admin extends Component { constructor(props) { super(props); this.state = {}; } render() { return (
<div className='animate-route'> <GlobalStyle /> <Header /> <Content>{this.props.children}</Content> <Footer /> </div> ); } } export default Admin;

 CSS添加如下代碼

.animate-route {
    animation-duration: 1s;
    animation-fill-mode: both;
    animation-name: fadeRoute;
}

@keyframes fadeRoute {
    from {
        opacity: 0;
    }
    to {
      opacity: 1;
    }
}

  刷新網頁看看把......


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM