標籤:des style blog http java color
轉載http://xuzhihong1987.blog.163.com/blog/static/26731587201312821725913/
功能說明:
雙擊查看大圖,滑鼠滾動放大縮小,能夠切換到上一張和下一張,點擊右上方關閉,相容主流的瀏覽器。
效果:
(例子一效果)
(例子二效果:注,如果第一張的時候,左側就不會顯示前一張箭頭,最後一張類似)
如何使用:(include)
1、樣式 twiPicZoom.css
2、jQuery的類庫,不一定要用1.8.3,其他的版本也行。
3、滑鼠滾動放大縮小需要用到 jquery.mousewheel.js
4、核心 jquery.twiPicZoom.js
<link href="../../twiPicZoom/twiPicZoom.css" rel="stylesheet" type="text/css" />
<script src="../../jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.mousewheel.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.twiPicZoom.js" type="text/javascript"></script>
在代碼中對選擇的對像直接使用twiPicZoom()方法。
$(function () {
$(‘img[type="twiPicZoom"]‘).twiPicZoom();
});
例子1:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../twiPicZoom/twiPicZoom.css" rel="stylesheet" type="text/css" />
<script src="../../jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.mousewheel.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.twiPicZoom.js" type="text/javascript"></script>
<title>查看圖片大圖</title>
<script type="text/javascript">
$(function () {
$(‘img[type="twiPicZoom"]‘).twiPicZoom();
});
</script>
</head>
<body>
<div id="imgContainer">
<img style="width:160px;height:120px;" src="../../samplePictures/Desert.jpg" type="twiPicZoom"/>
<img style="width:160px;height:120px;" src="../../samplePictures/Hydrangeas.jpg" type="twiPicZoom"/>
<img style="width:160px;height:120px;" src="../../samplePictures/Lighthouse.jpg" type="twiPicZoom"/>
<img style="width:160px;height:120px;" src="../../samplePictures/Jellyfish.jpg" type="twiPicZoom"/>
</div>
</body>
</html>
例子2:(複雜的結構,選擇的不是圖片對象,也可配置屬性)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../twiPicZoom/twiPicZoom.css" rel="stylesheet" type="text/css" />
<script src="../../jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.mousewheel.js" type="text/javascript"></script>
<script src="../../twiPicZoom/jquery.twiPicZoom.js" type="text/javascript"></script>
<title>查看圖片大圖/更改配置</title>
<script type="text/javascript">
$(function () {
$(‘div[type="twiPicZoom"]‘).twiPicZoom({srcField:‘href‘});
});
</script>
<style type="text/css">
#imgContainer div
{
display:inline-block;
}
</style>
</head>
<body>
<div id="imgContainer">
<div type="twiPicZoom" href="../../samplePictures/Desert.jpg">
<img style="width:160px;height:120px;" src="../../samplePictures/Desert.jpg" />
<h2>Desert</h2>
</div>
<div type="twiPicZoom" href="../../samplePictures/Hydrangeas.jpg">
<img style="width:160px;height:120px;" src="../../samplePictures/Hydrangeas.jpg"/>
<h2>Hydrangeas</h2>
</div>
<div type="twiPicZoom" href="../../samplePictures/Lighthouse.jpg">
<img style="width:160px;height:120px;" src="../../samplePictures/Lighthouse.jpg"/>
<h2>Lighthouse</h2>
</div>
<div type="twiPicZoom" href="../../samplePictures/Jellyfish.jpg">
<img style="width:160px;height:120px;" src="../../samplePictures/Jellyfish.jpg"/>
<h2>Jellyfish</h2>
</div>
</div>
</body>
</html>
源碼:
twiPicZoom 1.0 :http://www.kuaipan.cn/file/id_50389080302682261.htm