我试图使用CSS3过渡来动画CSS clip没有成功.图像只是剪辑而没有过渡.
我错过了什么?
#clipped {
position:absolute;
width: auto;
clip: rect(100, 100, 100, 100);
-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
}
#clipped:hover {
clip: rect(50px, 200px, 200px, 0);
}
Run Code Online (Sandbox Code Playgroud)
Ste*_*ald 15
你的代码工作得很好.你只需要给它正确的"开始"值,如下所示:
img {
position: absolute;
display: block;
clip: rect(10px, 100px, 200px, 0);
-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
}
img:hover {
clip: rect(80px, 200px, 250px, 50px);
}Run Code Online (Sandbox Code Playgroud)
<img src="http://i.stack.imgur.com/Wr86X.jpg">Run Code Online (Sandbox Code Playgroud)
根据该网站,rect不支持百分比.
如果你知道图像的大小,你可以这样做:DEMO
#clipped {
clip: rect(0, 350px, 350px, 0);
}
Run Code Online (Sandbox Code Playgroud)
或者不使用350px,您可以使用更大的数字来容纳更大的图像.您可能需要使用数字来获得均匀的动画.