最近看到一些好看的hover的图形缩放效果。然后自己就写了下,发现这2种效果都不错。如果伙伴们更好的实现方式可以在下面留言哦~

还有美团的效果,我就不展示了,喜欢的可以去app应用上看看。

这两种效果,其实实现的原理是一样的,就是用伪类选择器改变背景大小/图片大小。加一个过渡

    <!--腾讯新闻效果-->
<a href="javascript:void(0);" class="hover-body hover-body-weixin">
<i></i>
<span></span>
</a>
<!--美图APP效果-->
<a href="javascript:void(0);" class="hover-body-app third-party-app">
<i></i>
</a>

腾讯新闻小logo:外部的a标签实现点击跳转,我这里设置不跳转,i标签使用伪元素代表前景色和背景色,伪元素定位在里面,然后用缩放属性,在伪元素后面放过渡效果

.hover-body {
position: relative;
display: inline-block;
width: 48px;
height: 48px;
} .hover-body:hover i::after {
transform: scale(1);
} .hover-body span {
position: relative;
display: block;
width: 48px;
height: 48px;
background-size: 30px;
background-position: center;
background-repeat: no-repeat;
} .hover-body i {
position: absolute;
top:;
left:;
width: 48px;
height: 48px;
} .hover-body i::before {
content: '';
border-radius: 50%;
position: absolute;
top:;
left:;
right:;
bottom:;
} .hover-body i::after {
content: '';
transition: all .3s;
border-radius: 50%;
position: absolute;
top:;
left:;
right:;
bottom:;
transform: scale(0);
} .hover-body.hover-body-weixin span {
background-image: url(index.png);
} .hover-body.hover-body-weixin i::before {
background-color: pink;
} .hover-body.hover-body-weixin i::after {
background-color: palegoldenrod;
}

美团app仿效果:css,直接在i标签里放背景图片,设置伪元素before和after为2张图片,给图片放大小,加过渡

.hover-body-app{
position: relative;
display: inline-block;
width: 48px;
height: 48px;
margin-left: 6%;
margin-right: 6%;
}
.hover-body-app:hover i::after{
transform: scale(1);
} .hover-body-app i{
position: absolute;
top:;
left:;
width: 48px;
height: 48px;
}
.hover-body-app i::before{
content: '';
border-radius: 50%;
position: absolute;
top:;
left:;
right:;
bottom:;
}
.hover-body-app i::after {
content: '';
transition: all .3s;
border-radius: 50%;
position: absolute;
top:;
left:;
right:;
bottom:;
transform: scale(0);
} .hover-body-app.third-party-app i::before {
background: url(index.png);
background-size: 30px;
background-position: center;
background-repeat: no-repeat;
} .hover-body-app.third-party-app i::after {
background: url(indexfull.png);
background-size: 30px;
background-position: center;
background-repeat: no-repeat;
}

最新文章

  1. 清空form表单
  2. poj1155
  3. nc 常用命令
  4. Nginx return 关键字配置小技巧
  5. Discuz! X3.1去除内置门户导航/portal.php尾巴的方法
  6. WebGL自学教程——WebGL演示样例:開始
  7. 8.20.1 图形化:弹窗JOptionPane
  8. Java Persistence/ManyToMany
  9. c++ 库函数cmath
  10. Bootstrap3基础 下载bootstrap3压缩包和相应的jQuery文件
  11. (PMP)第1章-----引论
  12. 11:12:21.924 [main] DEBUG org.apache.ibatis.logging.LogFactory - Logging initialized using &#39;class org.apache.ibatis.logging.slf4j.Slf4jImpl&#39; adapter.
  13. Bash远程代码执行漏洞(CVE-2014-6271)案例分析
  14. LuaFileSystem
  15. vue安装流程
  16. 面试:C++二叉树遍历(递归/非递归)
  17. spring 事务传播行为实例分析
  18. 深入浅出SIP协议
  19. VBscript实现开机自动启动,自动复制原件后启动
  20. iOS 事件的产生、传递、响应

热门文章

  1. JDBC的异常
  2. Canon iP2780/iP2788 清零软件
  3. Java导出jar并运行
  4. Eclipse 搭建tomcat+动态项目完整版
  5. Vue.js父子通信之所有方法和数据共享
  6. 无线安全课堂:手把手教会你搭建伪AP接入点
  7. 离线安装Cloudera Manager5.3.4与CDH5.3.4
  8. 使用Maven对JAVA程序打包-带主类、带依赖
  9. 11种常见sqlmap使用方法
  10. Python学习笔记_Python对象