jquery - css3圖片抖動
問題描述
我這個點擊document彈出圖片他會抖動,不知道是怎么回事?要是把外層的sdf去了他又是正常的,要怎么改
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Document</title> <style>.sdf{ width:500px; height:500px; overflow:hidden; margin:200px auto; position:relative;} .outter{ width:174px; height:155px; position:absolute; top:100px; left:200px; transition:all 1s ease; } .dd{ background:url(http://www.ppt123.net/beijing/UploadFiles_8374/201203/2012032518062306.jpg); overflow:hidden; background-size:174px 155px; background-position:center center; transition:all 1s ease; width:0px; height:155px; margin:0 auto; } </style></head><body> <p class='sdf'><img src='http://img06.sephome.com/201602/D2D5B00588B8488496F37014622724F9.jpeg' src='http://img06.sephome.com/201602/D2D5B00588B8488496F37014622724F9.jpeg' alt='' style='display: inline;'><p class='outter'> <p class=’dd’></p></p> </p> <script src='http://cdn.bootcss.com/jquery/2.2.1/jquery.js'></script> <script>$(function() { $(document).on(’click’, function() { $('.dd').css({ ’width’:’174px’ }) }); }); </script></body></html>
問題解答
回答1:[doge]這根本沒有涉及 css3 好不,你就是單純的改變一個p的寬度,p的寬度原來占據(jù)的位置是0,你通過js來改變它的寬度,就會觸發(fā)瀏覽器的重繪。
建議是使用 transform:scale(0); 縮放元素,點擊之后在還原 transform:scale(1);,這樣就不會觸發(fā)瀏覽器的重繪了。
回答2:受1樓啟發(fā)
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Document</title> <style>.sdf{ width:500px; height:500px; overflow:hidden; margin:200px auto; position:relative;} .outter{ width:174px; height:155px; position:absolute; top:100px; left:200px; transition:all 1s ease; } .dd{ background:url(http://www.ppt123.net/beijing/UploadFiles_8374/201203/2012032518062306.jpg); overflow:hidden; background-size:174px 155px; background-position:center center; transition:all 1s ease; transform: scale(0,1); width:174px; height:155px; margin:0 auto; } </style></head><body> <p class='sdf'><img src='http://img06.sephome.com/201602/D2D5B00588B8488496F37014622724F9.jpeg' src='http://img06.sephome.com/201602/D2D5B00588B8488496F37014622724F9.jpeg' alt='' style='display: inline;'><p class='outter'> <p class=’dd’></p></p> </p> <script src='http://cdn.bootcss.com/jquery/2.2.1/jquery.js'></script> <script>$(function() { $(document).on(’click’, function() { $('.dd').css(’transform’, ’scale(1, 1)’); }); }); </script></body></html>回答3:
你把width縮小就是縮小一下,跟抖動并沒有什么關(guān)系啊。。說起來我理解的抖動不應(yīng)該是做一個animation,先向左transport再向右?
相關(guān)文章:
1. 數(shù)組按鍵值封裝!2. docker不顯示端口映射呢?3. java - 阿里的開發(fā)手冊中為什么禁用map來作為查詢的接受類?4. javascript - 使用vue官方腳手架進(jìn)行單元測試,如何覆蓋到watch里的變量?5. javascript - 為什么創(chuàng)建多行多列的表格最后只有一行內(nèi)有表格6. 如何用Java向kafka發(fā)送json數(shù)據(jù)7. javascript - webpack中alias配置中的“@”是什么意思?8. clone - git sourceTree克隆倉庫時,都不停彈出Password Required彈窗,即時輸入正確的git賬號密碼還是彈出9. 主題切換問題,用過別人的webapp在后臺切換模板主題后手機(jī)端打開網(wǎng)頁就是切換到的主題了10. html5 - 使用echarts中的圖表 一個頁面導(dǎo)入了好幾個js圖表 實現(xiàn)echarts圖表隨著瀏覽器窗口變化而變化時出現(xiàn)了問題
