背景图片slide焦点图滑动,图片上面可以写文字
XML/HTML Code
- <div class="banner">
- <ul>
- <li style="background-image: url('img/sunset.jpg');">
- <div class="inner">
- <h1><A href="http://www.freejs.net/article_jiaodiantu_82.html">右侧带透明遮罩效果文字简要的jQuery焦点图代码</A></h1>
- </div>
- </li>
- <li style="background-image: url('img/wood.jpg');">
- <div class="inner">
- <h1><A href="http://freejs.net/article_fenye_49.html">Jquery, Ajax无刷新翻页,支持跳转页面</A></h1>
- </div>
- </li>
- </ul>
- </div>
JavaScript Code
- <script>
- if(window.chrome) {
- $('.banner li').css('background-size', '100% 100%');
- }
- $('.banner').unslider({
- arrows: true,
- fluid: true,
- dots: true
- });
- // Find any element starting with a # in the URL
- // And listen to any click events it fires
- $('a[href^="#"]').click(function() {
- // Find the target element
- var target = $($(this).attr('href'));
- // And get its position
- var pos = target.offset(); // fallback to scrolling to top || {left: 0, top: 0};
- // jQuery will return false if there's no element
- // and your code will throw errors if it tries to do .offset().left;
- if(pos) {
- // Scroll the page
- $('html, body').animate({
- scrollTop: pos.top,
- scrollLeft: pos.left
- }, 1000);
- }
- // Don't let them visit the url, we'll scroll you there
- return false;
- });
- </script>
原文地址:http://www.freejs.net/article_jiaodiantu_203.html