css - 动画 CSS 剪辑

标签 css

我正在尝试使用 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);
}

Fiddle

最佳答案

您的代码运行良好。你只需要给它正确的“开始”值,就像这样:

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);
}
<img src="http://i.stack.imgur.com/Wr86X.jpg">

关于css - 动画 CSS 剪辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21056199/

相关文章:

HTML 表格边框与单元格边框重叠

javascript - 嵌套 UL 高度

html - 如何用css从下到上垂直书写

html - 使用随机类名更改 div 的宽度

css - Angular mat-form-field textArea 无法启用水平调整大小

html - 删除正文和页脚之间不需要的空间

css - 水平对齐缩略图

javascript - 如何让这个由 Javascript 设置固定位置的 DIV 留在包含的 DIV 中?

css - 如果我输入媒体 ="screen"和不输入媒体有什么区别

html - 如何在响应式 Bootstrap 3 中反转列的顺序?