banner.ejs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <link rel="stylesheet" href="/stylesheets/banner.css">
  2. <div class="carousel-container">
  3. <button class="btn-prev">❮</button>
  4. <div class="carousel-images">
  5. <div class="item" style="display: flex; flex-direction: row; justify-content: center; align-items: center;">
  6. <img width="50%" src="http://color.jccytech.cn/thumbs/v2/page/480/5d8898684278e31afd9b6968.jpeg" alt="<%= translate.cuteCat[lang] %>">
  7. <div style="padding-right: 60px;">
  8. <h1><%= translate.cuteCat[lang] %></h1>
  9. <p class="cat-description"><%= translate.cuteCatDescription[lang] %></p>
  10. <a href="/play/5d8898684278e31afd9b6968" class="carousel-play-btn"><%= translate.play[lang] %></a>
  11. </div>
  12. </div>
  13. <div class="item" style="display: flex; flex-direction: row; justify-content: space-evenly; align-items: center;">
  14. <div>
  15. <h1><%= translate.daily[lang] %></h1>
  16. <div style="font-weight: bold; font-size: 20px; color: #aaa; padding-bottom: 20px;">2025/01/19</div>
  17. <a href="/play/6783978993b021143d362277" class="carousel-play-btn"><%= translate.play[lang] %></a>
  18. </div>
  19. <img width="40%" src="http://color.jccytech.cn/thumbs/v2/page/480/6783978993b021143d362277.jpeg" alt="<%= translate.daily[lang] %>">
  20. </div>
  21. <div class="item" style="position: relative; display: inline-block;">
  22. <img width="100%" src="https://color.jccytech.cn/res/coloring/album_cover/720/661cf6deaae27d6dda120bcc.jpeg" alt="<%= translate.cuteKids[lang] %>">
  23. <h3 style="position: absolute; top: 20px; left: 20px; color:#ccc; "><%= translate.album[lang] %></h3>
  24. <h1 style="position: absolute; top: 40px; left: 20px; color:white; "><%= translate.cuteKids[lang] %></h1>
  25. </div>
  26. <div class="item" style="position: relative; display: inline-block;">
  27. <img width="100%" src="https://color.jccytech.cn/res/coloring/album_cover/720/670e26713562c348e1b64db0.jpeg" alt="<%= translate.animalsHappyTime[lang] %>">
  28. <h3 style="position: absolute; top: 20px; left: 20px; color:#ccc; "><%= translate.album[lang] %></h3>
  29. <h1 style="position: absolute; top: 40px; left: 20px; color:white; "><%= translate.animalsHappyTime[lang] %></h1>
  30. </div>
  31. </div>
  32. <button class="btn-next">❯</button>
  33. </div>
  34. <script>
  35. document.addEventListener('DOMContentLoaded', function () {
  36. const carouselImages = document.querySelector('.carousel-images');
  37. const items = document.querySelectorAll('.carousel-images .item');
  38. const prevButton = document.querySelector('.btn-prev');
  39. const nextButton = document.querySelector('.btn-next');
  40. let currentIndex = 0;
  41. function showItem(index) {
  42. if (index >= items.length) {
  43. currentIndex = 0;
  44. } else if (index < 0) {
  45. currentIndex = items.length - 1;
  46. } else {
  47. currentIndex = index;
  48. }
  49. const offset = -currentIndex * 100; // 每张图片占100%宽度
  50. carouselImages.style.transform = `translateX(${offset}%)`;
  51. }
  52. prevButton.addEventListener('click', function () {
  53. showItem(currentIndex - 1);
  54. });
  55. nextButton.addEventListener('click', function () {
  56. showItem(currentIndex + 1);
  57. });
  58. });
  59. </script>