在线演示
鼠标经过或悬停时,图片会缓慢放大;鼠标离开,图片缓慢还原。 下图分别为:原图、鼠标经过
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{
width: 250px;
margin: 50px auto;
overflow: hidden;
}
div img{
width: 100%;
cursor: pointer;
transition: all 0.6s;
}
div img:hover{
transform: scale(1.2);
}
</style>
</head>
<body>
<div>
<img src="images/01.jpg" />
</div>
</body>
</html>
解析:
transform:scale()可以实现按比例放大或者缩小功能。 transition允许CSS的属性值在一定的时间区间内平滑过渡 可以调节放大倍数以及放大过程所用时间。
转载请注明原文地址: https://ju.6miu.com/read-15390.html