久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

html - css3 animation的問題.我也不知道如何描述

瀏覽:135日期:2023-07-26 16:40:34

問題描述

<!DOCTYPE HTML><html lang='en-US'><head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title></title> <style type='text/css'>*{margin:0;padding:0;}.wrapper{ width:500px; height:200px; border:1px solid red; margin:0 auto; overflow:hidden;}ul{ height:100px; outline:1px solid red}li{ list-style:outside none none;}ul:nth-child(3).active{ display:block; animation: animate ease-in-out 0s 0s ;}ul:nth-child(4).active{ display:block; animation: animate ease-in-out 1s .5s ;}ul:nth-child(5).active{ display:block; animation: animate ease-in-out 2s .5s ;}@keyframes animate{ 0%{height:0; } 100%{height:100%; }} </style></head><body> <p class='wrapper'><ul> <li></li> <li></li> <li></li> <li></li></ul><ul> <li></li> <li></li> <li></li> <li></li></ul><ul style=’background:red’> <li></li> <li></li> <li></li> <li></li></ul><ul style=’background:red’> <li></li> <li></li> <li></li> <li></li></ul><ul style=’background:red’> <li></li> <li></li> <li></li> <li></li></ul> </p> <p>click</p><script src='http://libs.baidu.com/jquery/1.9.0/jquery.js'></script><script type='text/javascript'> $(document).ready(function(){$(’p’).click(function(){ $(’p’).css(’height’, ’initial’); $(’ul:gt(1)’).toggleClass(’active’);}); });</script></body></html>

現(xiàn)在這個效果肯定不滿意, 當我觸發(fā)事件時是一下跳出來了,因為height:auto了,然后動畫才開始!!

要的效果是一個一個出來.

多用動畫, 進軍移動端了

問題解答

回答1:

ul:nth-child(3).active{display:block;animation: animate ease-in-out 0s 0s backwards; } ul:nth-child(4).active{display:block;animation: animate ease-in-out 1s .5s backwards; } ul:nth-child(5).active{display:block;animation: animate ease-in-out 2s .5s backwards; } @keyframes animate{0%{ transform:scaleY(0);}100%{ transform:scaleY(1);} }

上面是修改方法。 無論是keyframes還是transition不要用height width,left,top,bottom,right等會引起reflow的屬性來作為變化參數(shù)。這段代碼里面,使用height來作為變化屬性導(dǎo)致了這個錯誤,因為height在不斷的改變,p的高度也在改變,導(dǎo)致瀏覽器一直在重排后來不及重繪,看到的就只有最后一下子跳出來的樣子。這段代碼放在移動端估計會讓手機更卡頓。另外keyframe animation transform等如果在移動端記得加webkit前綴。

標簽: HTML
相關(guān)文章:
主站蜘蛛池模板: 清镇市| 修水县| 桓仁| 石嘴山市| 榕江县| 八宿县| 项城市| 南充市| 湘阴县| 扬州市| 中宁县| 鹤山市| 鄂伦春自治旗| 普定县| 手游| 汨罗市| 奉节县| 交口县| 崇仁县| 阜康市| 西丰县| 灵宝市| 习水县| 万山特区| 青海省| 葫芦岛市| 长乐市| 永济市| 绥棱县| 万荣县| 拉孜县| 阳春市| 濉溪县| 富阳市| 财经| 洱源县| 鱼台县| 新巴尔虎右旗| 临西县| 东方市| 泊头市|