<h2>淡入效果 - 从上至下</h2>
<p>鼠标移动到图片上查看效果</p>
<div class="container">
<img src="https://statiwww.jyshare.com/images/mix/img_avatar.png" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
输入 JavaScript 代码……
xxxxxxxxxx
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #008CBA;
overflow: hidden;
height:0;
transition: .5s ease;
.container:hover .overlay {
bottom: 0;
height: 100%;
.text {
white-space: nowrap;
color: white;
font-size: 20px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);