这就是我正在寻找的:
我用html和css裁剪了一个图像,但不知道如何在其中放置矩形。我想动画我应该在div中使用:hover
类crop
类。
我的代码:http://jsfiddle.net/8t2hmxmn/
答案 0 :(得分:1)
我想这可以满足您的需求,调整细节元素的高度,只需修改height:
.details
值
html * {
box-sizing: border-box;
}
.crop {
background-image: url('http://cs628119.vk.me/v628119319/10059/Ag3oy3YU6wY.jpg');
width: 200px;
height: 150px;
background-position: center;
background-size: cover;
position: relative;
overflow: hidden;
}
.shape {
width: 200px;
height: 50px;
color: black;
}
.details {
position: absolute;
bottom: -100%;
left: 0;
right: 0;
height: 100%;
background: rgba(0, 0, 0, 0.5);
padding: 5px 10px;
transition: all 1s;
color: white;
}
.crop:hover > .details {
bottom: 0;
}

<div class="shape">
<div class="crop">
<div class="details">
Yes, this is cat!
</div>
</div>
</div>
&#13;