..."를 추가한 다음 필요에 따라 CSS 스타일을 변경하고 추가하세요. 필요할 때 캐러셀이 구현된 곳에 js 코드를 추가하기만 하면 됩니다."> phpcms에서 캐러셀을 구현하는 방법-PHPCMS-php.cn

phpcms에서 캐러셀을 구현하는 방법

藏色散人
풀어 주다: 2020-07-21 09:59:21
원래의
3177명이 탐색했습니다.
phpcms에서 캐러셀을 구현하는 방법: 먼저 캐러셀 이미지를 추가하려는 위치에 "
...
"를 추가한 다음 필요에 따라 CSS 스타일을 변경합니다. , 캐러셀을 구현해야 하는 곳에 js 코드를 추가합니다.

phpcms에서 캐러셀을 구현하는 방법

회전식 이미지를 구현하는 Phpcms 홈페이지

1. 회전식 이미지를 추가하려는 위치에 다음

{pc:content action="position" posid="1" thumb="1" order="listorder DESC" num="5"} {loop $data $r}
{$r[title]}
{/loop} {/pc}
    {pc:content action="lists" catid="" thumb="1" order="listorder DESC" num="5"} {loop $data $r}
  • {str_cut($r[title],20)}
  • {/loop} {/pc}
< >
로그인 후 복사

을 추가하세요.

이 초점 슬라이드는 특별하므로 그림과 텍스트를 두 번 호출해야 합니다. 추가로, 배경 컨텐츠 추가시 홈페이지 포커스 이미지 추천을 꼭 확인하시고, 홈페이지에 추가하시면 됩니다. 추천: "

phpcms tutorial"

2 물론 여기 CSS 스타일은 변경될 수 있습니다. 필요에 따라 여기에 게시하지 않겠습니다. 캐러셀을 구현하려면 다음 js 코드를 추가해야 합니다.

window.onload=function(){//获取元素 var flowDiagram = document.getElementById('flowDiagram');//容器 var photo = document.getElementById("photo"); var button = document.getElementById("button").getElementsByTagName('span'); var pre = document.getElementById("pre"); var next = document.getElementById("next"); var index = 1; var m; function move(){ m = setInterval(next.onclick,3000); } function stop(){ if(m)clearInterval(m); } function buttonlight(){ for (var i = 0; i < button.length; i++) { if(button[i].className == "on"){ button[i].className = ""; break; } } button[index-1].className = "on"; } pre.onclick=function() { if (index == 1) index = 5; else index = index - 1; buttonlight(); photo.style.left = parseInt(photo.style.left) + 1200 + "px"; if (parseInt(photo.style.left) > -1200){ photo.style.left = -6000 + "px"; } } next.onclick = function(){//当right键被触发时响应 if (index == 5) index = 1; else index = index + 1; buttonlight(); photo.style.left = parseInt(photo.style.left) - 1200 + "px"; if (parseInt(photo.style.left) < -6000){ photo.style.left = -1200 + "px"; } } for (var i = 0; i < button.length; i++){ button[i].onclick = function() { if(this.className=="on") return; var currentindex = parseInt(this.getAttribute("index"));//getAttribute能获取自定义的属性值,也可以获取自带的属性值 var distance = currentindex - index; photo.style.left = parseInt(photo.style.left) - 1200 * distance + "px"; index = currentindex; buttonlight(); } } flowDiagram.onmouseover = stop; flowDiagram.onmouseout = move; move(); }
로그인 후 복사
최종 효과

phpcms에서 캐러셀을 구현하는 방법

위 내용은 phpcms에서 캐러셀을 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!