css鼠标悬停背景图放大
时间: 2023-11-27 22:47:30 浏览: 96
以下是一个简单好看的鼠标悬停图文列表CSS3动画特效,实现了鼠标悬停图片时中间的圆形文字背景放大的效果:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CSS3鼠标悬停图文列表动画特效</title>
<style type="text/css">
ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
li {
margin: 20px;
position: relative;
overflow: hidden;
width: 300px;
height: 300px;
border-radius: 50%;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
transition: all 0.3s ease-in-out;
}
li:hover {
transform: scale(1.1);
box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}
li img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
transition: all 0.3s ease-in-out;
}
li:hover img {
transform: scale(1.2);
}
li::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0;
height: 0;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 50%;
transition: all 0.3s ease-in-out;
z-index: -1;
}
li:hover::before {
width: 200%;
height: 200%;
}
li h3 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
padding: 0;
font-size: 24px;
color: #333;
transition: all 0.3s ease-in-out;
z-index: 1;
}
li:hover h3 {
color: #fff;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}
</style>
</head>
<body>
<ul>
<li>
<img src="https://picsum.photos/300/300?random=1">
<h3>图片1</h3>
</li>
<li>
<img src="https://picsum.photos/300/300?random=2">
<h3>图片2</h3>
</li>
<li>
<img src="https://picsum.photos/300/300?random=3">
<h3>图片3</h3>
</li>
<li>
<img src="https://picsum.photos/300/300?random=4">
<h3>图片4</h3>
</li>
<li>
<img src="https://picsum.photos/300/300?random=5">
<h3>图片5</h3>
</li>
<li>
<img src="https://picsum.photos/300/300?random=6">
<h3>图片6</h3>
</li>
</ul>
</body>
</html>
```
阅读全文