background-size搭配transition实现鼠标hover背景图放大问题

background-size的默认值是cover,必须要保证是统一类型的值才能实现过渡效果

无效写法

li {
        padding: 26px 28px 0;
        border-bottom: 1px solid #fff;
        border-right: 1px solid #fff;
        background: url(../images/qiyezhan/pic1.png) no-repeat center;
        &:hover {
          background-size: 120%;
          -webkit-transition: background-size .3s linear;
          transition: background-size .3s linear;
        }
}

  正确写法

li {
        padding: 26px 28px 0;
        border-bottom: 1px solid #fff;
        border-right: 1px solid #fff;
        background: url(../images/qiyezhan/pic1.png) no-repeat center;
        background-size: 100%;
        &:hover {
          background-size: 120%;
          -webkit-transition: background-size .3s linear;
          transition: background-size .3s linear;
        }
}

  成功实现过渡放大背景效果

转载于:https://www.cnblogs.com/wszxx/p/10684803.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单好看的鼠标悬停图文列表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> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值