原創|使用教程|編輯:龔雪|2014-01-15 09:07:23.000|閱讀 468 次
概述:本文將為你介紹在Kentico?CMS中如何使用jQuery集成圖像縮放效果。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
在使用Kentico CMS進行網站內容建設的時候,你是否希望有這樣的效果:當用戶在你的網上商店瀏覽圖像時,用戶只要在圖像區域移動光標,圖像就隨之出現放大或縮小的畫面,從而可以看清更多的細節?通過下面簡單的幾步,你就可以做到:
一、復制以下腳本到你的母版頁的<head>部分,即CMS Desk -> Content -> <root document> -> Master page 下面并保存它。注意該腳本引用了兩個文件——multizoom.css和multizoom.js,所以一定要確保路徑設置正確無誤。點擊下載這兩個文件壓縮包。
<link rel="stylesheet" href="multizoom.css" type="text/css" /> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script type="text/javascript" src="multizoom.js"> // Featured Image Zoomer (w/ optional multizoom and adjustable power)- By Dynamic Drive DHTML code library (www.dynamicdrive.com) // Multi-Zoom code (c)2012 John Davenport Scheuer // as first seen in //www.dynamicdrive.com/forums/ // username: jscheuer1 - This Notice Must Remain for Legal Use // Visit Dynamic Drive at //www.dynamicdrive.com/ for this script and 100s more </script> <_script type="text/javascript"> jQuery(document).ready(function($){ $('#image1').addimagezoom({ // single image zoom zoomrange: [3, 10], magnifiersize: [300,300], magnifierpos: 'right', cursorshade: true, largeimage: 'hayden.jpg' //<-- No comma after last option! }) $('#image2').addimagezoom() // single image zoom with default options $('#multizoom1').addimagezoom({ // multi-zoom: options same as for previous Featured Image Zoomer's addimagezoom unless noted as '- new' descArea: '#description', // description selector (optional - but required if descriptions are used) - new speed: 1500, // duration of fade in for new zoomable images (in milliseconds, optional) - new descpos: true, // if set to true - description position follows image position at a set distance, defaults to false (optional) - new imagevertcenter: true, // zoomable image centers vertically in its container (optional) - new magvertcenter: true, // magnified area centers vertically in relation to the zoomable image (optional) - new zoomrange: [3, 10], magnifiersize: [250,250], magnifierpos: 'right', cursorshadecolor: '#fdffd5', cursorshade: true //<-- No comma after last option! }); $('#multizoom2').addimagezoom({ // multi-zoom: options same as for previous Featured Image Zoomer's addimagezoom unless noted as '- new' descArea: '#description2', // description selector (optional - but required if descriptions are used) - new disablewheel: true // even without variable zoom, mousewheel will not shift image position while mouse is over image (optional) - new //^-- No comma after last option! }); }) <_/script>
二、使用在上面代碼中你定義的jQuery選擇器為圖像設置腳本。默認情況下,有4個選擇器可供選擇——‘image1’、‘image2’、‘multizoom1’、‘multizoom2’。圖像需要明確定義尺寸(寬度和高度),這樣就能確保腳本在任何時候都能依據原始圖像的比例正確調整放大圖像的大小。(選擇器可用的所有選項都可以在官方網站www.dynamicdrive.com/dynamicindex4/featuredzoomer.htm 上找到)。
()
三、最后,你可能需要設置jQuery 到noConflict()模式使其能夠正常運作。
該腳本可以免費用于個人或商業網站。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網