<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>鼠标滑过图片显示文字</title>
<style>
.item {
width: 350px;
height: 260px;
margin: 50px auto;
position: relative;
perspective: 1000px;
border: 1px solid #ccc;
}
.wrapper {
width: 350px;
height: 260px;
position: absolute;
left: 0;
top: 0;
z-index: 100;
transition: all 0.5s linear;
}
.wrapper img {
width: 100%;
height: 100%;
}
.desc {
position: absolute;
top: 0;
left: 0;
width: 350px;
height: 260px;
line-height: 260px;
text-align: center;
font-size: 18px;
background-color: rgba(0, 0, 0, .1);
transform-style: preserve-3d;
transform-origin: center right;
transform: rotateY(-90deg);
transition: all 0.5s linear;
}
.item:hover .wrapper {
cursor: pointer;
transform: translateX(-180px) scale(0.5);
}
.item:hover .desc {
opacity: 1;
transform: rotateY(0deg);
}
</style>
</head>
<body>
<div class="item">
<div class="wrapper">
<img src="./images/张大大.jpg" alt="">
</div>
<div class="desc">张大大什么时候直播欸</div>
</div>
</body>
</html>
效果展示:
鼠标滑过图片滚动