查看效果:https:///keleyi/phtml/jqplug/9.htm
本特效使用的 jQuery 版本僅支援 1.9.0 以下,例如不支援 jquery1.10.2。它利用 bgStretcher 外掛,可讓背景圖片自動切換,並支援多種轉場效果與方向。程式碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jquery 背景自動切換特效-</title>
<link rel="stylesheet" type="text/css" href="https:///keleyi/phtml/jqplug/9/main.css" />
<link rel="stylesheet" type="text/css" href="https:///keleyi/phtml/jqplug/9/bgstretcher.css" />
<script src="https:///keleyi/pmedia/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript" src="https:///keleyi/phtml/jqplug/9/bgstretcher.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('BODY').bgStretcher({
images: ['https:///keleyi/phtml/jqplug/9/images/sample-1.jpg'
, 'https:///keleyi/phtml/jqplug/9/images/sample-2.jpg'
, 'https:///keleyi/phtml/jqplug/9/images/sample-3.jpg'
, 'https:///keleyi/phtml/jqplug/9/images/sample-4.jpg'
, 'https:///keleyi/phtml/jqplug/9/images/sample-5.jpg'
, 'https:///keleyi/phtml/jqplug/9/images/sample-6.jpg'],
imageWidth: 1024,
imageHeight: 768,
slideDirection: 'N',
slideShowSpeed: 1000,
transitionEffect: 'fade',
sequenceMode: 'normal',
buttonPrev: '#prev',
buttonNext: '#next',
pagination: '#nav',
anchoring: 'left center',
anchoringImg: 'left center'
});
});
</script>
</head>
<body>
<div><h1>背景圖片自動切換··Background Stretcher jQuery Plugin Demo</h1></div>
</body>
</html>
適用瀏覽器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗。