html css过渡小案例 鼠标悬浮文字出现背景图旋转放大
shanghai.png 图片
代码如下
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>38-过渡小案例</title>
<style>
.outer{
width: 210px;
height: 180px;
border: 1px solid black;
position: relative;
overflow: hidden;
}
.mask{
width: 210px;
height: 180px;
font-size: 70px;
color: white;
text-align: center;
line-height: 180px;
position: absolute;
background-color: black;
opacity: 0;
top: 0;
left: 0;
transition: 0.5s linear;
}
.outer:hover .mask{
opacity: 0.7;
cursor: pointer;
}
.outer:hover img{
transition: 0.5s linear;
}
.outer:hover img {
transform: scale(1.5) rotate(10deg);
}
</style>
</head>
<body>
<div class="outer">
<img src="shanghai.png" alt="">
<div class="mask">上海</div>
</div>
</body>
</html>