phpcms에서 캐러셀을 구현하는 방법: 먼저 캐러셀 이미지를 추가하려는 위치에 "..."를 추가한 다음 필요에 따라 CSS 스타일을 변경합니다. , 캐러셀을 구현해야 하는 곳에 js 코드를 추가합니다.
회전식 이미지를 구현하는 Phpcms 홈페이지
1. 회전식 이미지를 추가하려는 위치에 다음
<div id="flowDiagram" > <div id="button"> <span index="1" class="on"></span> <span index="2"></span> <span index="3"></span> <span index="4"></span> <span index="5"></span> </div> <div id="photo" style="left:-1200px;"> <div> {pc:content action="position" posid="1" thumb="1" order="listorder DESC" num="5"} {loop $data $r} <div ><a href="{$r[url]}" target="_blank" title="{$r[title]}"><img src="/static/imghwm/default1.png" data-src="{thumb($r[thumb],1200,320)}" class="lazy" style="max-width:90%" alt="{$r[title]}" /></a></div> {/loop} {/pc} <ul> {pc:content action="lists" catid="" thumb="1" order="listorder DESC" num="5"} {loop $data $r} <li><a href="{$r[url]}" target="_blank" title="{$r[title]}">{str_cut($r[title],20)}</a></li> {/loop} {/pc} </ul> <div></div> </div> </div> <span id="pre" class="arrow"> <</span> <span id="next" class="arrow">> </span> </div>
을 추가하세요.
이 초점 슬라이드는 특별하므로 그림과 텍스트를 두 번 호출해야 합니다. 추가로, 배경 컨텐츠 추가시 홈페이지 포커스 이미지 추천을 꼭 확인하시고, 홈페이지에 추가하시면 됩니다. 추천: "phpcms tutorial"
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에서 캐러셀을 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

WebStorm Mac 버전
유용한 JavaScript 개발 도구
