今天给大家分享的是用css怎样实现鼠标悬浮图片缩放的内容,下文有用纯CSS实现的代码供大家参考,实现原理是比较简单的,对新手学习CSS有一定的帮助,感兴趣的朋友接下来跟随小编一起看看吧。
代码如下:
<!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>Document</title>
<script></script>
<style>
* {
box-sizing: border-box;
}
body {
background-color: rgb(251, 163, 163);
}
/* 长条图样式 */
.containlist {
position: relative;
margin-top: 100px;
margin-left:10%;
height: 100px;
width: 80%;
overflow: hidden;
border-radius: 30px;
box-shadow: rgb(54, 53, 53) 10px 10px 10px;
}
.list {
position: absolute;
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
border-radius: 30px;
transition: 0.5s;
color: white;
font-weight: bold;
text-align: center;
}
.list:hover {
transform: scale(1.2);
}
</style>
</head>
<body>
<h1 style="text-align: center;color: white;background-color: black;">效果测试</h1>
<!-- 长条图 -->
<div class="containlist">
<div class="list" style="background-image: url(006.jpg);">
和服の少女
</div>
</div>
<div class="containlist">
<div class="list" style="background-image: url(001.png);">
天空の-R
</div>
</div>
<div class="containlist">
<div class="list" style="background-image: url(002.png);">
紫の景色
</div>
</div>
<div class="containlist">
<div class="list" style="background-image: url(003.png);">
私は一番可-郅い扦-
</div>
</div>
</body>
</html>
实际效果:

git图

图片的样式可以自行进行更改,打造你自己的中二风格。
以上就是用css实现鼠标悬浮图片缩放效果的代码,感兴趣的朋友可以了解看看,希望本文对大家学习CSS有帮助,想要了解更多CSS的使用技巧,大家可以继续浏览群英网络其他相关的文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理