banner.ejs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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="https://pcoloring.com/thumbs/coloring-page/page/480/5d8898684278e31afd9b6968.jpeg"
  7. alt="<%= translate.cuteCat[lang] %>">
  8. <div style="padding-right: 60px;">
  9. <h1>
  10. <%= translate.cuteCat[lang] %>
  11. </h1>
  12. <p class="cat-description">
  13. <%= translate.cuteCatDescription[lang] %>
  14. </p>
  15. <a href="/play/5d8898684278e31afd9b6968" class="carousel-play-btn">
  16. <%= translate.play[lang] %>
  17. </a>
  18. </div>
  19. </div>
  20. <div class="item" style="display: flex; flex-direction: row; justify-content: space-evenly; align-items: center;">
  21. <div>
  22. <h1>
  23. <%= translate.daily[lang] %>
  24. </h1>
  25. <div style="font-weight: bold; font-size: 20px; color: #aaa; padding-bottom: 20px;">
  26. <%= today%>
  27. </div>
  28. <a href="/play/6783978993b021143d362277" class="carousel-play-btn">
  29. <%= translate.play[lang] %>
  30. </a>
  31. </div>
  32. <img width="40%" src="<%=daily.artInfo.thumb%>" alt="<%= translate.daily[lang] %>">
  33. </div>
  34. <div class=" item" style="position: relative; display: inline-block;">
  35. <img width="100%" src="https://pcoloring.com/res/coloring/album_cover/720/661cf6deaae27d6dda120bcc.jpeg"
  36. alt="<%= translate.coloringPageAlbum[lang] %>: <%= translate.cuteKids[lang] %>">
  37. <h3 style="position: absolute; top: 20px; left: 20px; color:#ccc; ">
  38. <%= translate.coloringPageAlbum[lang] %>
  39. </h3>
  40. <h1 style="position: absolute; top: 40px; left: 20px; color:white; ">
  41. <%= translate.cuteKids[lang] %>
  42. </h1>
  43. </div>
  44. <div class="item" style="position: relative; display: inline-block;">
  45. <img width="100%" src="https://pcoloring.com/res/coloring/album_cover/720/670e26713562c348e1b64db0.jpeg"
  46. alt="<%= translate.coloringPageAlbum[lang] %>: <%= translate.animalsHappyTime[lang] %>">
  47. <h3 style="position: absolute; top: 20px; left: 20px; color:#ccc; ">
  48. <%= translate.coloringPageAlbum[lang] %>
  49. </h3>
  50. <h1 style="position: absolute; top: 40px; left: 20px; color:white; ">
  51. <%= translate.animalsHappyTime[lang] %>
  52. </h1>
  53. </div>
  54. </div>
  55. <button class="btn-next">❯</button>
  56. </div>
  57. <script>
  58. document.addEventListener('DOMContentLoaded', function () {
  59. const carouselImages = document.querySelector('.carousel-images');
  60. const items = document.querySelectorAll('.carousel-images .item');
  61. const prevButton = document.querySelector('.btn-prev');
  62. const nextButton = document.querySelector('.btn-next');
  63. let currentIndex = 0;
  64. function showItem(index) {
  65. if (index >= items.length) {
  66. currentIndex = 0;
  67. } else if (index < 0) {
  68. currentIndex = items.length - 1;
  69. } else {
  70. currentIndex = index;
  71. }
  72. const offset = -currentIndex * 100; // 每张图片占100%宽度
  73. carouselImages.style.transform = `translateX(${offset}%)`;
  74. }
  75. prevButton.addEventListener('click', function () {
  76. showItem(currentIndex - 1);
  77. });
  78. nextButton.addEventListener('click', function () {
  79. showItem(currentIndex + 1);
  80. });
  81. });
  82. </script>