html怎么实现点小图变大图,css实现悬浮在图片上,图片缓缓变大

最近写了一个小demo,图片缓缓放大,很好玩

鼠标悬浮在图片上时,字体大小不变,多了边框,图片变大为2倍,移开鼠标恢复原样,作为页面的一个动效还是蛮好看的。

效果类似于这样:

230f86497c20

原始图片

230f86497c20

鼠标悬浮时

代码如下:

.card {

width: 50%;

margin: 0 auto;

padding: 20px;

}

.card:hover {

box-shadow: 0 0 25px rgba(186, 204, 207, 0.7);

}

.card:hover .scale {

transform: scale(2);

}

.image {

height: 200px;

overflow: hidden;

position: relative;

}

.scale {

position: absolute;

z-index: 0;

width: 100%;

height: 100%;

background: url('https://images.unsplash.com/photo-1544209207-8d2b21f3c5fe?ixlib=rb-1.2.1&q=99&fm=jpg&crop=entropy&cs=tinysrgb&w=2048&fit=max&ixid=eyJhcHBfaWQiOjcwOTV9') no-repeat center;

background-size: cover;

transition: all 0.6s ease;

}

.title {

width: 100%;

text-align: center;

color: #fff;

font-size: 24px;

line-height: 200px;

position: absolute;

}

悬浮图片变大
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值