文章詳情頁
css3 - transition用js改變class不能實現過渡效果嗎?怎樣才能實現呢?
瀏覽:169日期:2023-06-29 09:15:56
問題描述
當監聽到事件時,更改class,但是看不到過渡效果。transition用js改變class不能實現過渡效果嗎,怎樣才能實現呢?
.search-page { position: fixed; top: 88px; left: 0; width: 100%; height: 100%; z-index: 200; transition: all 0.4s linear; -webkit-transition: all 0.4s linear; &.unactive{display: none;opacity: 0; background-color: rgba(7,17,27,0); } &.search-active {display: block;opacity: 1;background-color: rgba(7,17,27,0.6); } }
問題解答
回答1:你用display: none之后,他就會直接執行,然后被隱藏,你看不到過渡的效果。。。
你可以在trasition的回調函數里面使他display: none;
xxx.addEventListener(’transitionend’, function () { , false);
在動畫結束后對他進行操作,也可連續動畫。
標簽:
CSS
相關文章:
1. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””2. docker-compose中volumes的問題3. boot2docker無法啟動4. nignx - docker內nginx 80端口被占用5. docker安裝后出現Cannot connect to the Docker daemon.6. docker容器呢SSH為什么連不通呢?7. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值8. dockerfile - 為什么docker容器啟動不了?9. java - SSH框架中寫分頁時service層中不能注入分頁類10. 關于docker下的nginx壓力測試
排行榜

網公網安備