-
2016-07-11 11:27:47<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>鼠标滑过,缩略图放大显示</title>
<style type="text/css">
<!--
* {margin:0;padding:0;}
img {border:0}
#imgmove li {float:left; width:50px; height:40px; display:block; overflow:visible;*overflow:hidden; margin:0px 5px; border:3px #333 solid; position:relative;*position:static;}
#imgmove a img {position:absolute;left:0px;top:0px;clip:rect(0px 50px 40px 0px);z-index: 0;*position:static;}
#imgmove a:hover {border:none }
#imgmove a:hover img {position:relative; left:-3px; top:-3px; border:3px #f00 solid; z-index:2; clip:rect(0px 137px 137px 0px);}
-->
</style>
</head>
<body>
<br />
<ul id="imgmove">
<li><a href="#"><img src="wall1.jpg" /></a></li>
<li><a href="#"><img src="wall2.jpg" /></a></li>
</ul>
</body>
</html>更多相关内容 -
鼠标滑过缩略图时放大图片(纯Css)
2020-10-30 13:13:28鼠标滑过缩略图时放大图片(纯Css) -
鼠标移上缩略图放大图片的纯CSS代码
2021-05-12 06:53:31内容索引:脚本资源,CSS特效,图片放大 你的鼠标移上缩略图就会放大该图片的一款纯CSS特效代码,很酷很牛,相信不会让你后悔,用纯CSS实现,演示图如上示,源码爱好者稍微修改了下。这种效果可以用作相册或产品预览页... -
jQuery+CSS超炫的鼠标经过缩略图放大图片效果
2021-05-12 09:36:47内容索引:脚本资源,jQuery,图片放大 jQuery+CSS超炫的鼠标经过缩略图放大图片效果,不用多介绍了吧?现在网页上有很多这种类似的效果,像淘宝网、拍拍网等各大购物网站以及产品一类的网站很常见,同样使用了jQuery... -
jQuery左右滚动支持图片放大缩略图图片轮播代码分享
2020-11-23 06:15:15本文实例讲述了jQuery左右滚动支持图片放大缩略图图片轮播效果。分享给大家供大家参考。具体如下: 这是一款基于jQuery实现的左右滚动支持图片放大缩略图图片轮播效果,常用的jQuery图片左右轮播效果,同时支持底部... -
jQuery 结合 CSS完成淘宝网产品列表图片放大效果
2021-05-01 15:18:43内容索引:脚本资源,Ajax/JavaScript,jQuery,图片放大 jQuery 结合 CSS实现的淘宝...也不需要另外上传缩略图,程序将调用原图片生成缩略图,放大后的图片实际上是原图片的大校觉得这个功能挺实用,特此上传奉献给大家。 -
jquery缩略图放大镜效果
2018-09-01 10:17:02实现带缩略图的放大镜效果,适合在网站开发使用,希望能给给为带来帮助 -
缩略图放大镜.rar
2020-05-01 19:35:36用html+css+jquery实现图片放大,效果如淘宝点击缩略图对应图片放大,l里面有素材和源码,jQuery实现点击图片简单放大效果,主要包括jQuery实现点击图片简单放大效果使用实例、应用技巧、基本知识点,有需要的可以... -
JavaScript 鼠标滑过,缩略图放大显示(纯CSS).rar
2019-12-11 18:42:51JavaScript 鼠标滑过,缩略图放大显示(纯CSS).rarJavaScript 鼠标滑过,缩略图放大显示(纯CSS).rarJavaScript 鼠标滑过,缩略图放大显示(纯CSS).rarJavaScript 鼠标滑过,缩略图放大显示(纯CSS).rarJavaScript ... -
鼠标滑过,缩略图放大显示(纯CSS).rar
2019-12-02 14:21:30鼠标滑过,缩略图放大显示(纯CSS).rar鼠标滑过,缩略图放大显示(纯CSS).rar鼠标滑过,缩略图放大显示(纯CSS).rar鼠标滑过,缩略图放大显示(纯CSS).rar鼠标滑过,缩略图放大显示(纯CSS).rar鼠标滑过,缩略图放大... -
html+css+js 实现缩略图点击放大商品图,跟随鼠标放大图片
2021-05-14 23:22:25转载借鉴: ...优化了代码,结合两位老师的代码,组合实现了,点击商品显示对应商品大图的效果跟,商品放大镜的效果 <!DOCTYPE html> <html lang="en"> <head> <meta charset.转载借鉴:
https://www.jianshu.com/p/499ddf24c49c
https://blog.csdn.net/weixin_44606660/article/details/86604963
如有侵权联系删除
实现如下效果
优化了代码,结合两位老师的代码,组合实现了,点击商品显示对应商品大图的效果跟,商品放大镜的效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="js/main.js" type="text/javascript" charset="utf-8"></script> <!--实现css--> <style type="text/css"> /*这里是选择跟整体设计开始*/ ul, li { list-style: none; padding-left: 0px; } .box { width: 900px; height: 500px; text-align: left; } #pic { width: 500px; height: 500px; margin-top: 30px; } ul li { width: 90px; height: 100px; text-align: center; float: left; margin-right: 10px; border: 1px solid gray; } ul li img { width: 100%; height: 100%; } ul li:hover img { width: 100%; ; height: 100%; ; } ul li.sel { border-color: red; //border-width: 1.5px; } ul li.sel img { width: 100%; ; height: 100%; ; #curPic:hover { cursor: move; } } /*这里是选择跟整体设计结束*/ /*从这边开始是放大图片处理css*/ #curPic img { width: 500px; height: 500px; } #mgf { display: none; position: absolute; top: 0; left: 0; background-color: rgba(255, 230, 93, 0.3); width: 250px; height: 250px; } #boxEnlarge { display: none; position: absolute; top: 35px; left: 520px; overflow: hidden; } /*放大处理结束*/ </style> </head> <body> <div class="box"> <!--设置放大镜的html代码块开始--> <div id="parent"> <div id="curPic"> <div id="mgf"></div> <img src="img/dd1.jpg" alt="" class="small-img" id="pic"> </div> <div id="boxEnlarge"> <img src="img/dd1.jpg" alt="" class="small-img" id="pic"> </div> </div> <!--设置放大镜的html代码块结束--> <!--设置选择图片的html代码开始--> <ul> <li class="sel"><img src="img/dd1.jpg" alt=""></li> <li><img src="img/dd2.jpg" alt=""></li> <li><img src="img/dd3.jpg" alt=""></li> <li><img src="img/dd4.jpg" alt=""></li> <li><img src="img/dd5.jpg" alt=""></li> </ul> <!--设置选择图片的html代码结束--> </div> <!--设置选择图片js代码--> <script type="text/javascript"> var lis = document.getElementsByTagName("ul")[0].getElementsByTagName('li'); //li var oImg = document.getElementById('pic'); //为li添加单击事件 for(var i = 0; i < lis.length; i++) { lis[i].onclick = function() { oImg.src = this.children[0].src; for(var j = 0; j < lis.length; j++) { lis[j].className = ""; } this.className = "sel"; }; } </script> <!--设置放大镜的代码--> <script type="text/javascript"> var parent = document.getElementById('parent'); var curpic = document.getElementById('curPic'); var mgf = document.getElementById("mgf"); var boxEnlarge = document.getElementById("boxEnlarge"); /*鼠标移至图片范围时,显示‘放大镜’和放大区域*/ curpic.onmouseover = function() { var mgf = document.getElementById("mgf"); mgf.style.display = "block"; boxEnlarge.style.display = "block"; } /*鼠标移出图片范围时,隐藏‘放大镜’和放大区域*/ curpic.onmouseout = function() { var mgf = document.getElementById("mgf"); mgf.style.display = "none"; boxEnlarge.style.display = "none"; } curpic.onmousemove = function() { Move(); } function Move(e) { /*根据‘放大镜’和放大倍数设置放大区域大小*/ boxEnlarge.style.width = mgf.offsetWidth * 2 + 'px'; boxEnlarge.style.height = mgf.offsetHeight * 2 + 'px'; /*鼠标移至‘放大镜’中心*/ e = e || event; var mgfx = e.clientX - curpic.offsetLeft - parent.offsetLeft - mgf.offsetWidth / 2; var mgfy = e.clientY - curpic.offsetTop - parent.offsetTop - mgf.offsetHeight / 2; if(mgfx < 0) { mgfx = 0; } if(mgfx >= curpic.offsetWidth - mgf.offsetWidth) { mgfx = curpic.offsetWidth - mgf.offsetWidth; } if(mgfy < 0) { mgfy = 0; } if(mgfy >= curpic.offsetHeight - mgf.offsetHeight) { mgfy = curpic.offsetHeight - mgf.offsetHeight; } mgf.style.left = mgfx + 'px'; mgf.style.top = mgfy + 'px'; /*设置放大的图片尺寸并根据‘放大镜’的移动调整显示区域*/ var pic = boxEnlarge.children[0]; pic.style.width = curpic.offsetWidth * 2 + 'px'; pic.style.height = curpic.offsetHeight * 2 + 'px'; pic.style.marginLeft = ((-1) * mgf.offsetLeft * 2) + 'px'; pic.style.marginTop = ((-1) * mgf.offsetTop * 2) + 'px'; } </script> </body> </html>
素材:
-
HTML+jquery实现缩略图放大
2015-06-02 10:26:09通过jquery,实现页面上的缩略图放大功能,简单、易用、易懂。 自带样式、js、页面等全部代码。 -
jQuery左右滚动支持图片放大缩略图图片轮播代码
2020-06-11 04:32:36常用的jQuery图片左右轮播效果,同时支持底部缩略图左右滚动展示 点击大图片后支持放大效果 使用方法: 1、将head中的js以及css拷贝到你的网页中 2、将代码部分拷贝到你需要的地方即可 3、注意... -
JS实现鼠标移动到缩略图显示大图的图片放大效果
2021-01-19 19:15:50一个网页上用的图片提示效果,当把鼠标移动到图片缩略图的时候,会显示图片大图,似乎在网上这是个很常见的效果,实现方法也比较多,有人用CSS,有人用JavaScript,有人用jQuery,总之,选择自己习惯的方式去实现,... -
点击缩略图,放大图片,大图以轮播的形式展现
2019-01-16 11:01:42点击缩略图,放大图片,大图以轮播的形式展现,轮播图中默认展现当前点击的图片 -
纯js制作商城缩略图产品局部放大特效
2019-11-17 22:19:56纯js制作商城缩略图产品局部放大特效 -
纯CSS实现的带缩略图预览相册代码
2021-01-23 05:12:38纯CSS实现的带缩略图预览相册代码 -
纯CSS方法鼠标悬停时放大缩略图.rar
2019-07-10 19:17:31纯CSS方法鼠标悬停时放大缩略图,把鼠标放在缩略图上时,缩略图会变大显示,类似于图片放大的功能,不过不太一样,这一款应该归类为CSS的悬停特效上,纯CSS代码实现,无使用任何的JavaScript代码。 -
picturepriview:原生js图片预览插件,仿淘宝京东图片放大及缩略图预览
2021-05-14 14:49:35picturepriview 原生js图片预览插件,仿淘宝京东图片放大及缩略图预览。 -
jQuery+css实现的点击图片放大缩小预览功能示例【图片预览 查看大图】
2020-10-15 06:28:43主要介绍了jQuery+css实现的点击图片放大缩小预览功能,结合实例形式分析了jQuery+css控制图片放大、缩小预览查看的相关操作技巧,需要的朋友可以参考下 -
jquery图像幻灯片全屏图片相册点击缩略图片放大查看预览
2019-11-17 21:27:32jquery图像幻灯片全屏图片相册点击缩略图片放大查看预览 jquery图像幻灯片全屏图片相册点击缩略图片放大查看预览 jquery图像幻灯片全屏图片相册点击缩略图片放大查看预览 -
jQuery类似放大镜缩略图切换.zip
2019-07-04 22:56:05jQuery类似放大镜缩略图切换是一款带缩略图和左右按钮图标按钮的焦点图,缩略图切换类似放大镜效果。 -
css3缩略图点击放大
2016-09-06 12:30:01 -
css按照比例缩小图片:实现缩略图的办法
2021-06-12 00:56:12先上css代码:.content img{max-width:50px;max-height:50px;}*html.content img{width:expression(this.width>50&&this.width>this.height?50:auto);height:expresion(this.height>50?50:auto);}...先上css代码:
.content img{max-width:50px;max-height:50px;}
*html.content img{width:expression(this.width>50&&this.width>this.height?50:auto);
height:expresion(this.height>50?50:auto);}
如果你深谙css及各版本浏览器的习性,应该能搞清楚上面代码的亮点。
把一副大图片按比例缩小到某个尺寸,对于现代浏览器,直接使用max-width和max-height两条CSS属性即可。
对于IE 6.0及以下版本,以上两条CSS属性均不会被理会。之前处理这种事情,我们往往会借助Javascript,然后为图片加上onload事件。
这固然能解决问题,但是对以后页面的升级会带来麻烦——随着浏览器对CSS支持的完善,我们迟早会把图片上的onload事件统统去除。该是 Expression的Show Time了,既然IE支持通过Expression在CSS中放置一些脚本,而这段脚本又只是提供给IE 6.0及以下版本使用,那么把它写到Expression中再合适不过。
最终,把一副大图片按比例缩小到50px*50px以内,可以参照以文章开头这段CSS。为了方便,避免重复,我们甚至可以直接将css写到一个标签样式里,即如下,写在一起。
max-width:150px;
height:auto;
max-height:150px;
width:auto;
width:expression(this.width>150&&this.width>this.height?150:auto);
height:expresion(this.height>150?150:auto);
而用图则可以表示为如下图片。如果你用wordpress建站,搭配auto-highslide插件,就能实现本站文章内图片的放大缩小效果了,有兴趣就试试吧!
不过,在wordpress里你完全不用为此操心,因为wordpress本身已经带了图片大小控制功能,在后台“设置》媒体”中有一项为:最大嵌入对象大小,它的功能就是将文章中的图片按照设定的最大尺寸来放置,即图片超过你设置的长度或宽度时,按照比例缩小图片。本站的设置如下:
-
多缩略图 图片放大镜 magiczoomplus
2012-09-14 09:42:45这是一个带多缩略图且带放大镜的jquery代码插件,它呈现了小图、中图、大图的过渡,是产品展示的好插件,功能强大,使用方便。 -
jQuery类似放大镜缩略图切换特效代码
2021-03-20 04:27:20jQuery类似放大镜缩略图切换是一款带缩略图和左右按钮图标按钮的焦点图,缩略图切换类似放大镜效果。 -
基于threejs的炫酷缩略图到全屏放大动画特效
2019-12-12 20:34:16这是一款基于threejs的炫酷缩略图到全屏放大动画特效。该特效通过使用threejs。在用户点击缩略图时,将缩略图已某种炫酷的动画方式展开到全屏。 -
jQuery教程 css+jQuery实现图片局部放大预览
2021-06-27 03:03:37本篇教程介绍了jQuery教程 css+jQuery实现图片局部放大预览,希望阅读本篇文章以后大家有所收获,帮助大家对jQuery的理解更加深入。<今天有时间开始动手,使用css+jqueryshi实现了...右边放大图div,背景为缩略图的...本篇教程介绍了jQuery教程 css+jQuery实现图片局部放大预览,希望阅读本篇文章以后大家有所收获,帮助大家对jQuery的理解更加深入。
<
今天有时间开始动手,使用css+jqueryshi实现了图片局部放大的组件,首先看看效果图:
界面设计思路如下:
1.两个div,左边放图片的缩略图 2.在左边缩略图鼠标移动的时候,区域(效果图中的网格) 3.右边放大图div,背景为缩略图的大图,在鼠标移入缩略图中,通过获取鼠标的坐标,将右侧背景图片移动到跟鼠标坐标对应的位置 4.设计时尽量,获取原大图的尺寸,和缩略图视窗计算比例,更大精度的做到左侧缩略图上表示的区域,和右侧放大部分匹配
本示例大部分编码在javascript脚本,以下列出各部分的源码:
css:
.all-region {
width: 100%;
height: auto;
}
.all-region .image-wrap {
width: 1300px;
margin: 0px auto;
height: 300px;
line-height: 300px;
overflow: hidden;
vertical-align: center;
background: #FBFBFB;
border-left: 1px solid #ebebeb;
position: relative;
}
.image-wrap .little-img img {
width: 600px;
height: 300px;
}
.image-wrap .large-img {
width: 600px;
height: 300px;
background-image: url("./images/show-window/timg.jpg");
border: 1px solid transparent;
background-size: inherit;
background-repeat: no-repeat;
background-position-x: 0px;
background-position-y: 0px;
position: relative;
top: -301px;
left: 605px;
float: left;
z-index: 10;
opacity: 0;
display: none;
transition: opacity 2s linear;
overflow: hidden;
}
.relative-region {
background: linear-gradient(45deg, rgba(46, 46, 46, 0.5) 50%, transparent 0),
linear-gradient(135deg, rgba(200, 200, 200, .5) 70%, transparent 0);
display: none;
position: relative;
z-index: 99;
background-size: 5px 5px;
}
Javascript:
class Elements {
constructor() {
//缩略图区域
this.sourceImage = $(".little-img");
//放大区域
this.aimImage = $(".large-img");
//视图图片,与图片实际尺寸比例
this.sourceToAimRate = 0.01;
//原图高度
this.sourceHeight = 0;
//原图宽度
this.sourceWidth = 0;
//视图高度,div的高度,本例是300px
this.containerHeight = this.sourceImage.children().height();
this.containerWidth = this.sourceImage.children().width();
//鼠标在缩略图上的坐标 offsetX
this.cursor_x = 0;
this.cursor_y = 0;
//标志被放大的区域
this.region = $(".relative-region");
this.mouseMove = this.mouseMove.bind(this);
this.regionPosition = this.regionPosition.bind(this);
this.regionMove = this.regionMove.bind(this);
this.caculatorRate = this.caculatorRate.bind(this);
}
//计算原图尺寸,思路是内存加载原图,获得尺寸,并计算容器视图和原图的比例
caculatorRate() {
console.log(this.sourceImage.children().attr("src"));
$("").attr("src", this.sourceImage.children().attr("src")).load((e) => {
//let sourceImageWidth=e.target.width;
this.sourceWidth = e.target.width;
this.sourceHeight = e.target.height;
//计算图片和容器的像素比例
this.sourceToAimRate = this.sourceWidth / this.containerWidth;
});
}
//鼠标在缩略图上移动时计算,放大图的背景位置,并且定位标识被放大的区域
mouseMove(e) {
//console.log(`x:${e.offsetX},y:${e.offsetY}`);
//偏离region的位置
//由于鼠标实际上是在标识被放大区域(网格区域)的div里面,所以通过e获取的实际上是缩略图内,网格标识的offsetX 要用网格区域的offsetX+offsetLeft-缩略图的offsetleft才是鼠标对应到缩略图上的位置
let r_x = e.offsetX;
let r_y = e.offsetY;
let s_t = this.sourceImage.offset().top;
let s_l = this.sourceImage.offset().left;
let r_t = this.region.offset().top;
let r_l = this.region.offset().left;
let x = r_l - s_l + r_x;
let y = r_t - s_t + r_y;
//在原图上显示,被放大的区域
let w = this.region.width();
let h = this.region.height();
//由于鼠标在网格区域的中心,所以在计算放大图的top和left的时候,实际是从网格的左上角位置
this.cursor_x = (x - w / 2) * this.sourceToAimRate;
this.cursor_y = (y - h / 2) * this.sourceToAimRate;
if (this.cursor_x + this.containerWidth > this.sourceWidth) {
this.cursor_x = this.sourceWidth - this.containerWidth;
}
if (this.cursor_y + this.containerHeight > this.sourceHeight) {
this.cursor_y = this.sourceHeight - this.containerHeight;
}
if (this.cursor_y
this.cursor_y = 0;
}
if (this.cursor_x
this.cursor_x = 0;
}
this.aimImage.css({
"background-position-x": -this.cursor_x + "px",
"background-position-y": -this.cursor_y + "px"
});
this.regionMove(w, h, x, y);
}
regionPosition(r_w, r_h, e) {
let left = e.offsetX - r_w / 2;
let top = e.offsetY - r_h / 2;
if (left
left = 0;
}
if (left + r_w > this.containerWidth) {
left = this.containerWidth - r_w;
}
if (top
top = 0;
}
if (top + r_h > this.containerHeight) {
top = this.containerHeight - r_h;
}
this.region.css({
"top": (top - this.containerHeight) + "px",
"left": left+ "px",
"cursor": "crosshair"
});
}
regionMove(r_w, r_h, x, y) {
let left = x - r_w / 2;
let top = y - r_h / 2;
if (left
left = 0;
}
if (left + r_w > this.containerWidth) {
left = this.containerWidth - r_w;
}
if (top
top = 0;
}
if (top + r_h > this.containerHeight) {
top = this.containerHeight - r_h;
}
this.region.css({"top": (top - this.containerHeight) + "px", "left": left + "px"});
}
init() {
this.caculatorRate();
//鼠标移入缩略图区域,由缩略图区域的hover事件初始化,将鼠标放入网格区域的中心
this.sourceImage.children().mouseover((e) => {
this.aimImage.css({"display": "block", "opacity": "1"});
let r_w = this.containerWidth / this.sourceToAimRate;
let r_h = this.containerHeight / this.sourceToAimRate;
let x = e.offsetX;
let y = e.offsetY;
this.regionPosition(r_w, r_h, e);
this.region.css({"display": "block", "height": r_h + "px", "width": r_w + "px"});
});
//修复鼠标在region上,右侧放大区域闪动
this.region.mousemove(this.mouseMove);
this.region.mouseleave(() => {
this.aimImage.css({"display": "none", "opacity": "0"});
this.region.css({"display": "none"});
});
}
}
$(function () {
var e = new Elements();
e.init();
})
由于原图是1920*1080不是缩略视窗严格的2:1,计算中有小数等原因,使网格标识的区域,和放大区域展示的完全匹配
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标WEB前端jQuery频道!
-
电商缩略图及放大镜
2016-05-26 10:45:51只有是电商类开发的缩略图和放大镜功能插件