2012-12-07 3 views
-1

내가 implent에 노력하고있어 슬라이더/회전 목마는 이것이다 : http://www.paulwelsh.info/jquery-plugins/hero-carousel/영웅 회전 목마 문제

나는 내가 시작 설계 웹 사이트와 약간의 경험 (때문에 드릴 수 없습니다하는, 그것을 위해 HTML 코드를 추가 할 필요가 있음을 알고 내 과정은 한 달 전). 이 코드가 작동하도록 추가해야하는 HTML 코드를 도와 주시겠습니까? 이것은 내 HTML, CSS & 자바 스크립트입니다. HTML은 분명히 틀림없이 보이는 것처럼 보입니다.

HTML

<div class="hero"> 
<div class="hero-carousel"> 


<article> 
    <img src="images/deadmau5/slide1.jpg" /> 

</article> 

<article> 
    <img src="images/deadmau5/slide2.jpg" /> 

</article> 

<article> 
    <img src="images/deadmau5/slide3.jpg" /> 

</article> 
<article> 

    <img src="images/deadmau5/slide4.jpg" /> 

</article> 

</div> 
</div> 
<script> 
    $(document).ready(function(){ 
     $('.hero-carousel').heroCarousel({ 
      easing: 'easeOutExpo', 
      css3pieFix: true 
     }); 
    }); 
</script> 

CSS

.hero { 
width: 100%; 
position: relative; 
overflow: hidden; 
margin-bottom: 48px; 
} 

.hero-carousel article { 
    width: 980px; 
    margin: 0 auto; 
    height: 480px; 
    display: block; 
    float: left; 
    position: relative; 
    } 

.hero-carousel-container article { 
    float: left; 
    } 

    .hero-carousel article img{ 
     position: absolute; 
     top: 0; 
     left: 0; 
     z-index: 1; 
     } 

    .hero-carousel article .contents { 
     position: relative; 
     z-index: 2; 
     top: 72px; 
     left: 48px; 
     list-style: none; 
     color: #000; 
     width: 556px; 
     padding: 20px; 

     background: rgba(255,255,255,0.8); 
     -pie-background: rgba(255,255,255,0.8); 

     -moz-border-radius: 20px; 
     -webkit-border-radius: 20px; 
     border-radius: 20px; 

     behavior: url(/assets/PIE.htc); 
     } 

    .hero-carousel-nav { 
     width: 980px; 
     position: absolute; 
     bottom: 0; 
     left: 50%; 
     margin-left: -490px; 
     z-index: 2; 
     } 

     .hero-carousel-nav li { 
      position: absolute; 
      bottom: 48px; 
      right: 48px; 
      list-style: none; 
      } 

     .hero-carousel-nav li.prev { 
      left: 48px; 
      right: auto; 
      } 

     .hero-carousel-nav li a { 
      background: #D21034; 
      color: #fff; 
      border: none; 
      outline: none; 
      display: block; 
      float: left; 
      padding: 5px 20px; 

      -moz-border-radius: 20px; 
      -webkit-border-radius: 20px; 
      border-radius: 20px; 
      behavior: url(/assets/PIE.htc); 
      } 

     .hero-carousel-nav li a:hover { 
      background: #89051C; 
      } 

     .hero-carousel-nav li a:active, 
     .hero-carousel-nav li a:focus { 
      border: none; 
      outline: none; 
      } 

자바 스크립트

jQuery.fn.heroCarousel=function(a){a=jQuery.extend({animationSpeed:1000,navigation:true,easing:"",timeout:5000,pause:true,pauseOnNavHover:true,prevText:"Previous",nextText:"Next",css3pieFix:false,currentClass:"current",onLoad:function(){},onStart:function(){},onComplete:function(){}},a);if(jQuery.browser.msie&&parseFloat(jQuery.browser.version)<7){a.animationSpeed=0}return this.each(function(){var k=jQuery(this),b=k.children();currentItem=1;childWidth=b.width();childHeight=b.height();if(b.length>2){b.each(function(m){if(a.itemClass){jQuery(this).addClass(a.itemClass)}});b.filter(":first").addClass(a.currentClass).before(b.filter(":last"));var d=Math.round(childWidth*k.children().length),l="-"+Math.round(childWidth+Math.round(childWidth/2))+"px";k.addClass("hero-carousel-container").css({position:"relative",overflow:"hidden",left:"50%",top:0,"margin-left":l,height:childHeight,width:d});k.before('<ul class="hero-carousel-nav"><li class="prev"><a href="#">'+a.prevText+'</a></li><li class="next"><a href="#">'+a.nextText+"</a></li></ul>");var e=k.prev(".hero-carousel-nav"),h;if(a.timeout>0){var j=false;if(a.pause){k.hover(function(){j=true},function(){j=false})}if(a.pauseOnNavHover){e.hover(function(){j=true},function(){j=false})}function c(){if(!j){e.find(".next a").trigger("click")}}h=window.setInterval(c,a.timeout)}e.find("a").data("disabled",false).click(function(p){p.preventDefault();var m=jQuery(this),n=m.parent().hasClass("prev"),o=k.children();if(m.data("disabled")===false){a.onStart(k,e,o.eq(currentItem),a);if(n){f(o.filter(":last"),"previous")}else{f(o.filter(":first"),"next")}m.data("disabled",true);setTimeout(function(){m.data("disabled",false)},a.animationSpeed+200);if(a.timeout>0){window.clearInterval(h);h=window.setInterval(c,a.timeout)}}});function f(m,q){var o=parseFloat(k.position().left),n=parseFloat(k.css("margin-left"));if(q==="previous"){m.before(m.clone().addClass("carousel-clone"));k.prepend(m);var p=Math.round(n-childWidth);var r="+="}else{m.after(m.clone().addClass("carousel-clone"));k.append(m);var p=l;var r="-="}if(a.css3pieFix){g(jQuery(".carousel-clone"))}k.css({left:o,width:Math.round(d+childWidth),"margin-left":p}).animate({left:r+childWidth},a.animationSpeed,a.easing,function(){k.css({left:"50%",width:d,"margin-left":n});jQuery(".carousel-clone").remove();i()})}function g(n){var m=n.attr("_pieId");if(m){n.attr("_pieId",m+"_cloned")}n.find("*[_pieId]").each(function(o,p){var q=$(p).attr("_pieId");$(p).attr("_pieId",q+"_cloned")})}function i(){var m=k.children();m.removeClass(a.currentClass).eq(currentItem).addClass(a.currentClass);a.onComplete(k,k.prev(".hero-carousel-nav"),m.eq(currentItem),a)}if(jQuery.browser.msie){e.find("a").attr("hideFocus","true")}a.onLoad(k,e,k.children().eq(currentItem),a)}})}; 
+0

링크 된 웹 페이지의 출처를 보시려면 – Luke

+0

매우 오래 있습니다. 모든 일은 이미지가 중앙에 놓이고 수직으로 표시되는 것입니다. 첫 번째 이미지는 첫 번째 이미지이고, 그 다음 이미지는 아래 이미지입니다. –

답변

1

당신은 마크 업 (T)를 변경해야 오 :

<div class="hero"> 
    <div class="hero-carousel"> 
    <article> 
     <img src="slide-1.jpg" /> 
     <div class="contents">text goes here</div> 
    </article> 
    <article> 
     <img src="slide-1.jpg" /> 
     <div class="contents">text goes here</div> 
    </article> 
    </div> 
</div> 

는 같은 jQuery마르크을 업 추가하는 것을 잊지 마십시오

<script> 
     $(document).ready(function(){ 
      $('.hero-carousel').heroCarousel({ 
       easing: 'easeOutExpo', 
       css3pieFix: true 
      }); 
     }); 
    </script> 

이 당신을 위해 작동합니다.

수정 - 유사한 문제를 해결하는 데 도움이되도록 inspect element 또는 view source을 사용해보세요.

+0

FireBug를 사용하고 있었고 찾고 찾고있었습니다 .. http://www.deadmau5.com과 비슷한 것을하려고합니다. 제가 사용하고있는 슬라이더가 똑같은 방식으로 작동해야합니다. 이전 이미지와 다음 이미지의 일부가 실제로 슬라이드됩니다. 코드가 일부 부분을 수정하여 실제 슬라이드로 만듭니다. 고정되어 있지 않은 것은 새로운 사진에서 "미끄러지 듯"하는 대신 그저 그런 그림을 변경한다는 것입니다. 이미지는 측면에도 표시되지 않습니다. 어떤 아이디어? 편집 : 기본적으로 그림을 전환하지 않습니다. –

+0

이전 이미지와 다음 이미지가 모두 표시되도록 관리합니다. 지금 당장 가지고있는 유일한 문제는 이미지를 스크롤하지 않는다는 것입니다. –

+0

프로토 타입을 어딘가에 업로드 할 수 있습니까? 나는'css'가이 오류의 원인일지도 모른다고 생각한다. – Boris