今天要给大家分享的的一款用纯css3实现的图片放大镜特效。页面打开五个小图显示于页面。当鼠标经过图片时,当前图片以灰色背景图的形式展示。效果非常不错。

在线预览   源码下载

实现的代码:

html代码:

  1. <ul class="gallery">
  2. <li class="gallery__item"></li>
  3. <li class="gallery__item"></li>
  4. <li class="gallery__item"></li>
  5. <li class="gallery__item"></li>
  6. <li class="gallery__item"></li>
  7. <li class="gallery__item"></li>
  8. </ul>

css代码:

  1. .gallery
  2. {
  3. list-style: none;
  4. }
  5. .gallery:before, .gallery__item:last-child
  6. {
  7. position: fixed;
  8. top: 50%;
  9. left: 50%;
  10. margin: -31.25em;
  11. width: 62.5em;
  12. height: 62.5em;
  13. }
  14. .gallery:before
  15. {
  16. z-index: -1;
  17. border-radius: 50%;
  18. content: '';
  19. box-shadow: inset 0 0 5em dimgrey, 0 0 0 50vw dimgrey;
  20. }
  21. .gallery__item
  22. {
  23. background-blend-mode: luminosity;
  24. transition: -webkit-transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-image 0.5s;
  25. }
  26. .gallery__item:not(:last-child)
  27. {
  28. position: absolute;
  29. top: 50%;
  30. left: 50%;
  31. width: 32vmin;
  32. height: 32vmin;
  33. border-radius: 50%;
  34. box-shadow: 0 0 .5em white;
  35. }
  36. .gallery__item:nth-child(1)
  37. {
  38. margin: 13.87457vmin -4.53223vmin;
  39. -webkit-transform: scale(0.5);
  40. background: url("imgs/1.jpg") 50% 50% fixed whitesmoke;
  41. }
  42. .gallery__item:nth-child(1):hover
  43. {
  44. -webkit-transform: scale(1);
  45. background-blend-mode: normal;
  46. cursor: pointer;
  47. }
  48. .gallery__item:nth-child(1):hover ~ :last-child
  49. {
  50. background: url("imgs/1.jpg") 50% 50% fixed dimgray;
  51. }
  52. .gallery__item:nth-child(1):hover ~ :last-child:after
  53. {
  54. opacity: .001;
  55. }
  56. .gallery__item:nth-child(2)
  57. {
  58. margin: 4.13825vmin -40.86867vmin;
  59. -webkit-transform: scale(0.5);
  60. background: url("imgs/2.jpg") 50% 50% fixed whitesmoke;
  61. }
  62. .gallery__item:nth-child(2):hover
  63. {
  64. -webkit-transform: scale(1);
  65. background-blend-mode: normal;
  66. cursor: pointer;
  67. }
  68. .gallery__item:nth-child(2):hover ~ :last-child
  69. {
  70. background: url("imgs/2.jpg") 50% 50% fixed dimgray;
  71. }
  72. .gallery__item:nth-child(2):hover ~ :last-child:after
  73. {
  74. opacity: .001;
  75. }
  76. .gallery__item:nth-child(3)
  77. {
  78. margin: -33.42845vmin -42.83746vmin;
  79. -webkit-transform: scale(0.5);
  80. background: url("imgs/3.jpg") 50% 50% fixed whitesmoke;
  81. }
  82. .gallery__item:nth-child(3):hover
  83. {
  84. -webkit-transform: scale(1);
  85. background-blend-mode: normal;
  86. cursor: pointer;
  87. }
  88. .gallery__item:nth-child(3):hover ~ :last-child
  89. {
  90. background: url("imgs/3.jpg") 50% 50% fixed dimgray;
  91. }
  92. .gallery__item:nth-child(3):hover ~ :last-child:after
  93. {
  94. opacity: .001;
  95. }
  96. .gallery__item:nth-child(4)
  97. {
  98. margin: -46.90963vmin -7.71779vmin;
  99. -webkit-transform: scale(0.5);
  100. background: url("imgs/4.jpg") 50% 50% fixed whitesmoke;
  101. }
  102. .gallery__item:nth-child(4):hover
  103. {
  104. -webkit-transform: scale(1);
  105. background-blend-mode: normal;
  106. cursor: pointer;
  107. }
  108. .gallery__item:nth-child(4):hover ~ :last-child
  109. {
  110. background: url("imgs/4.jpg") 50% 50% fixed dimgray;
  111. }
  112. .gallery__item:nth-child(4):hover ~ :last-child:after
  113. {
  114. opacity: .001;
  115. }
  116. .gallery__item:nth-child(5)
  117. {
  118. margin: -17.67475vmin 15.95615vmin;
  119. -webkit-transform: scale(0.5);
  120. background: url("imgs/5.jpg") 50% 50% fixed whitesmoke;
  121. }
  122. .gallery__item:nth-child(5):hover
  123. {
  124. -webkit-transform: scale(1);
  125. background-blend-mode: normal;
  126. cursor: pointer;
  127. }
  128. .gallery__item:nth-child(5):hover ~ :last-child
  129. {
  130. background: url("imgs/5.jpg") 50% 50% fixed dimgray;
  131. }
  132. .gallery__item:nth-child(5):hover ~ :last-child:after
  133. {
  134. opacity: .001;
  135. }
  136. .gallery__item:last-child
  137. {
  138. z-index: -2;
  139. }
  140. .gallery__item:last-child:after
  141. {
  142. position: absolute;
  143. top:;
  144. right:;
  145. bottom:;
  146. left:;
  147. opacity: .999;
  148. background: dimgrey;
  149. transition: opacity 2s;
  150. content: '';
  151. }

注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/5002

纯css3实现的创意图片放大镜的更多相关文章

  1. 8个超震撼的HTML5和纯CSS3动画源码

    HTML5和CSS3之所以强大,不仅因为现在大量的浏览器的支持,更是因为它们已经越来越能满足现代开发的需要.Flash在几年之后肯定会消亡,那么HTML5和CSS3将会替代Flash.今天我们要给大家 ...

  2. 11个超震撼的HTML5和纯CSS3动画源码

    1.jQuery多功能手风琴个人信息菜单面板 这是一款基于jQuery的手风琴个人信息菜单面板,每一个菜单项展开后可以自定义布局,因此可以为每一个菜单项实现多功能.类似这样的多功能菜单还有jQuery ...

  3. 纯CSS3实现的一些酷炫效果

    之前在网上看到一些用纯CSS3实现的酷炫效果,以为实现起来比较困难,于是想看看具体是怎么实现的. 一.笑脸猫动画 实现效果如下: 这个实现起来确实比较麻烦,很多地方需要花时间,有耐心地调整. 1.先看 ...

  4. 纯css3圆形从中心向四周扩散动画效果

    查看效果:http://hovertree.com/texiao/css3/37/ 先来个简单的示例,例如: @keyframes hovertreemove{from {top:30px;}to { ...

  5. 纯css3 3D图片立方体旋转动画特效

    纯css3 3D立方体模块,鼠标触碰,模块炸开,大立方体中套小立方体 效果展示 手机扫描二维码体验效果: 效果图如下: 源码下载:http://hovertree.com/h/bjaf/0qmul8g ...

  6. 纯CSS3实现多层云彩变换飞行动画

    查看效果:http://hovertree.com/texiao/css3/4/效果2 效果图: 代码如下: <!doctype html> <html lang="zh& ...

  7. 纯css3艺术文字样式效果代码

    效果:http://hovertree.com/texiao/css3/1/ 本效果主要使用text-shadow实现.参考:http://hovertree.com/h/bjaf/css3_text ...

  8. 纯css3手机页面图标样式代码

    全部图标:http://hovertree.com/texiao/css/19/ 先看效果: 或者点这里:http://hovertree.com/texiao/css/19/hoverkico.ht ...

  9. 纯CSS3实现动态火车行驶特效

    上次开完飞机,这次开火车 查看效果:http://hovertree.com/texiao/css3/7/ 效果图: 代码如下: <!DOCTYPE html> <html> ...

随机推荐

  1. 学习KNN

    转:© 著作权归作者所有 by ido 什么是KNN算法呢?顾名思义,就是K-Nearest neighbors Algorithms的简称.我们可能都知道最近邻算法,它就是KNN算法在k=1时的特例 ...

  2. Drupal administration theme

    Drupal允许为管理后台设置独立的theme,保存在系统变量variable_get('admin_theme'). Drupal使用全局变量$theme来保存当前请求对应的主题.Drupal在启动 ...

  3. Linux服务器修改时区时间

    时间的一致性很关键,对于日志的分析和程序的对接都至关重要! 01.tzselect 修改时区 可以使用命令 tzselect,修改时区.操作示例: $ tzselect Please identify ...

  4. servlet下根据相对路径找资源

    1.在web项目中如果直接添加一个资源,那么相对路径相对的是tomcat的bin目录. 2.在包中直接指定资源,那么可以使用以下的相对路径直接获取资源: InputStream in = this.g ...

  5. Ubuntu共享WiFi(AP)给Android方法

    更新: 2012-03-03      Android是不支持Ad-hoc模式的WiFi.Windows 7软AP一个还是比较简单的.本文介绍在Ubuntu下实现软AP.(需要你的无线网卡支持AP哈) ...

  6. cxf之java.lang.NoSuchMethodError: org.springframework.aop.support.AopUtils.isCglibProxyClass(Ljava/lang/C

    想用cxf发布一个web服务,但是容器启动报这个错,求高人解答啊 [问题点数:20分,无满意结帖,结帖人shijing266] 楼主好懒,主要还是jar版本的问题,spring4.2.0以上需要使用c ...

  7. 常见Web前端开发笔试题

    1.什么是web标准? WEB标准不是某一个标准,而是一系列标准的集合.网页主要由三部分组成:结构(Structure).表现(Presentation)和行为 (Behavior). 对应的标准也分 ...

  8. HighCharts: 设置时间图x轴的宽度

    这个x轴宽度的设置整了好久,被老板催的要死 highcharts的api文档很难找,找了半天也没找到,网上资料少,说的试了下,也没有,我用的图里api文档里没有介绍,这个属性不知道的话,根本不好找.为 ...

  9. RGB(FFFFFF)转255:255:255

    NSString *color = model.display_color; long colorLong = strtoul([color cStringUsingEncoding:NSUTF8St ...

  10. Effective C++:条款33:避免遮掩继承而来的名称

    (一) 以下这段代码: int x; void someFunc() { double x; //local variable std::cin>>x; //read a new valu ...