用纯css3实现的图片放大镜特效效果非常不错


Posted in HTML / CSS onSeptember 02, 2014

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

源码下载

实现的代码:

html代码:

复制代码
代码如下:

<ul class="gallery">
<li class="gallery__item"></li>
<li class="gallery__item"></li>
<li class="gallery__item"></li>
<li class="gallery__item"></li>
<li class="gallery__item"></li>
<li class="gallery__item"></li>
</ul>

css代码:
复制代码
代码如下:

.gallery
{
list-style: none;
}
.gallery:before, .gallery__item:last-child
{
position: fixed;
top: 50%;
left: 50%;
margin: -31.25em;
width: 62.5em;
height: 62.5em;
}
.gallery:before
{
z-index: -1;
border-radius: 50%;
content: '';
box-shadow: inset 0 0 5em dimgrey, 0 0 0 50vw dimgrey;
}
.gallery__item
{
background-blend-mode: luminosity;
transition: -webkit-transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-image 0.5s;
}
.gallery__item:not(:last-child)
{
position: absolute;
top: 50%;
left: 50%;
width: 32vmin;
height: 32vmin;
border-radius: 50%;
box-shadow: 0 0 .5em white;
}
.gallery__item:nth-child(1)
{
margin: 13.87457vmin -4.53223vmin;
-webkit-transform: scale(0.5);
background: url("imgs/1.jpg") 50% 50% fixed whitesmoke;
}
.gallery__item:nth-child(1):hover
{
-webkit-transform: scale(1);
background-blend-mode: normal;
cursor: pointer;
}
.gallery__item:nth-child(1):hover ~ :last-child
{
background: url("imgs/1.jpg") 50% 50% fixed dimgray;
}
.gallery__item:nth-child(1):hover ~ :last-child:after
{
opacity: .001;
}
.gallery__item:nth-child(2)
{
margin: 4.13825vmin -40.86867vmin;
-webkit-transform: scale(0.5);
background: url("imgs/2.jpg") 50% 50% fixed whitesmoke;
}
.gallery__item:nth-child(2):hover
{
-webkit-transform: scale(1);
background-blend-mode: normal;
cursor: pointer;
}
.gallery__item:nth-child(2):hover ~ :last-child
{
background: url("imgs/2.jpg") 50% 50% fixed dimgray;
}
.gallery__item:nth-child(2):hover ~ :last-child:after
{
opacity: .001;
}
.gallery__item:nth-child(3)
{
margin: -33.42845vmin -42.83746vmin;
-webkit-transform: scale(0.5);
background: url("imgs/3.jpg") 50% 50% fixed whitesmoke;
}
.gallery__item:nth-child(3):hover
{
-webkit-transform: scale(1);
background-blend-mode: normal;
cursor: pointer;
}
.gallery__item:nth-child(3):hover ~ :last-child
{
background: url("imgs/3.jpg") 50% 50% fixed dimgray;
}
.gallery__item:nth-child(3):hover ~ :last-child:after
{
opacity: .001;
}
.gallery__item:nth-child(4)
{
margin: -46.90963vmin -7.71779vmin;
-webkit-transform: scale(0.5);
background: url("imgs/4.jpg") 50% 50% fixed whitesmoke;
}
.gallery__item:nth-child(4):hover
{
-webkit-transform: scale(1);
background-blend-mode: normal;
cursor: pointer;
}
.gallery__item:nth-child(4):hover ~ :last-child
{
background: url("imgs/4.jpg") 50% 50% fixed dimgray;
}
.gallery__item:nth-child(4):hover ~ :last-child:after
{
opacity: .001;
}
.gallery__item:nth-child(5)
{
margin: -17.67475vmin 15.95615vmin;
-webkit-transform: scale(0.5);
background: url("imgs/5.jpg") 50% 50% fixed whitesmoke;
}
.gallery__item:nth-child(5):hover
{
-webkit-transform: scale(1);
background-blend-mode: normal;
cursor: pointer;
}
.gallery__item:nth-child(5):hover ~ :last-child
{
background: url("imgs/5.jpg") 50% 50% fixed dimgray;
}
.gallery__item:nth-child(5):hover ~ :last-child:after
{
opacity: .001;
}
.gallery__item:last-child
{
z-index: -2;
}
.gallery__item:last-child:after
{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: .999;
background: dimgrey;
transition: opacity 2s;
content: '';
}
HTML / CSS 相关文章推荐
CSS3美化表单控件全集
Jun 29 HTML / CSS
10个很棒的 CSS3 开发工具 推荐
May 16 HTML / CSS
一款纯css3实现的动画加载导航
Oct 08 HTML / CSS
图解CSS3制作圆环形进度条的实例教程
May 26 HTML / CSS
HTML+CSS3模拟心的跳动实例代码
Sep 05 HTML / CSS
web页面录屏实现
Feb 12 HTML / CSS
HTML5几个设计和修改的页面范例分享
Sep 29 HTML / CSS
全面解析HTML5中的标准属性与自定义属性
Feb 18 HTML / CSS
HTML5中使用json对象的实例代码
Sep 10 HTML / CSS
HTML5 Blob 实现文件下载功能的示例代码
Nov 29 HTML / CSS
CSS3中Animation实现简单的手指点击动画的示例
Jul 15 HTML / CSS
Unicode中的CJK(中日韩统一表意文字)字符小结
Dec 06 HTML / CSS
CSS3 中的@keyframes介绍
Sep 02 #HTML / CSS
CSS3 Pie工具推荐--让IE6-8支持一些优秀的CSS3特性
Sep 02 #HTML / CSS
css3中背景尺寸background-size详解
Sep 02 #HTML / CSS
css3中transition属性详解
Sep 02 #HTML / CSS
纯css3实现鼠标经过图片显示描述的动画效果
Sep 01 #HTML / CSS
纯css3实现效果超级炫的checkbox复选框和radio单选框
Sep 01 #HTML / CSS
css3设置box-pack和box-align让div里面的元素垂直居中
Sep 01 #HTML / CSS
You might like
php堆排序实现原理与应用方法
2015/01/03 PHP
Ubuntu 16.04下安装PHP 7过程详解
2017/03/28 PHP
[原创]保存的js无法执行的解决办法
2007/02/25 Javascript
检测是否已安装 .NET Framework 3.5的js脚本
2009/02/14 Javascript
extjs 为某个事件设置拦截器
2010/01/15 Javascript
图片img的src不变让浏览器重新加载实现方法
2013/03/29 Javascript
JavaScript解析URL参数示例代码
2013/08/12 Javascript
JS获取select-option-text_value的方法
2013/12/26 Javascript
jquery select 设置默认选中的示例代码
2014/02/07 Javascript
JQuery在循环中绑定事件的问题详解
2016/06/02 Javascript
javascript弹出窗口中增加确定取消按钮
2016/06/24 Javascript
微信小程序 教程之条件渲染
2016/10/18 Javascript
搭建Bootstrap离线文档的方法
2016/12/02 Javascript
Bootstrap CSS使用方法
2016/12/23 Javascript
Bootstrap路径导航与分页学习使用
2017/02/08 Javascript
nodejs 最新版安装npm 的使用详解
2018/01/18 NodeJs
原生js+css实现tab切换功能
2020/09/17 Javascript
[00:59]PWL开团时刻DAY7——我在赶
2020/11/06 DOTA
python list使用示例 list中找连续的数字
2014/01/27 Python
Python实现比较两个文件夹中代码变化的方法
2015/07/10 Python
Python的string模块中的Template类字符串模板用法
2016/06/27 Python
Python3学习urllib的使用方法示例
2017/11/29 Python
Python学习之Django的管理界面代码示例
2018/02/10 Python
对Python3中dict.keys()转换成list类型的方法详解
2019/02/03 Python
python多线程抽象编程模型详解
2019/03/20 Python
详解pandas使用drop_duplicates去除DataFrame重复项参数
2019/08/01 Python
pip已经安装好第三方库但pycharm中import时还是标红的解决方案
2020/10/09 Python
Wojas罗马尼亚网站:波兰皮鞋品牌
2018/11/01 全球购物
override和overload的区别
2016/03/09 面试题
外语专业毕业生个人的自荐信
2013/11/19 职场文书
死亡证明书样本说明
2014/10/18 职场文书
廉洁自律承诺书2015
2015/01/22 职场文书
介绍信的格式
2015/01/30 职场文书
2015年秘书个人工作总结
2015/04/25 职场文书
让文件路径提取变得更简单的Python Path库
2021/05/27 Python
Java 将PPT幻灯片转为HTML文件的实现思路
2021/06/11 Java/Android