使用“php语言”,我如何创建一个图片幻灯片,但主要是像Pinterest上的“图片旋转木马”的文本?[关闭]

bxgwgixi  于 2023-06-21  发布在  PHP
关注(0)|答案(1)|浏览(157)

已关闭,此问题需要更focused。目前不接受答复。
**想改善这个问题吗?**更新问题,使其仅通过editing this post关注一个问题。

7天前关闭
Improve this question
我在理解编码和计算机语言方面勉强算不上Maven,但我确实对它们很着迷。回到这个问题-那么,我如何创建一个表,文本可以插入内;如果单击箭头,则可以转到最后一张或下一张幻灯片,而没有任何动画。
我用php来做这个。
我的想法是:

  1. Slide #1 Slide #2
  2. ┏━━━━━━━━━━┓ ┏━━━━━━━━━━┓
  3. Hi there
  4. ┗━━━━━━━━━━┛ ┗━━━━━━━━━━┛

我最初是使用“人工智能”来生成文本的,结果几乎总是以我不希望的方式出现。

owfi6suc

owfi6suc1#

我不知道这是不是你需要的。我引用了别人的代码,并根据你的要求修改了它。
联系我们

  1. <div class="slideshow-container">
  2. <div class="mySlides fade">
  3. <div class="img">AAA</div>
  4. <div class="text">A</div>
  5. </div>
  6. <div class="mySlides fade">
  7. <div class="img">BBB</div>
  8. <div class="text">Two</div>
  9. </div>
  10. <div class="mySlides fade">
  11. <div class="img">CCC</div>
  12. <div class="text">Three</div>
  13. </div>
  14. <div class="mySlides fade">
  15. <div class="img">DDD</div>
  16. <div class="text">Four</div>
  17. </div>
  18. <a class="prev" onclick="plusSlides(-1)"></a>
  19. <a class="next" onclick="plusSlides(1)"></a>
  20. </div>

css:

  1. body {
  2. font-family: "Arial", "sans-serif";
  3. margin: 0 auto;
  4. }
  5. .mySlides {
  6. display: none;
  7. width: 100%;
  8. height: 100%;
  9. background: gray;
  10. }
  11. .img {
  12. color: #f2f2f2;
  13. font-size: 36px;
  14. padding: 5px 10px;
  15. position: absolute;
  16. top: 50%;
  17. left: 50%;
  18. transform: translate(-50%, -50%);
  19. text-align: center;
  20. border-radius: 20px;
  21. background: rgba(0, 0, 0, 0.5);
  22. }
  23. /* Slideshow container */
  24. .slideshow-container {
  25. width: 512px;
  26. height: 300px;
  27. position: relative;
  28. margin: 0 auto;
  29. }
  30. /* Next & previous buttons */
  31. .prev,
  32. .next {
  33. cursor: pointer;
  34. position: absolute;
  35. top: 50%;
  36. transform: translate(0%, -50%);
  37. width: auto;
  38. padding: 16px;
  39. color: white;
  40. font-weight: bold;
  41. font-size: 18px;
  42. border-radius: 10px;
  43. user-select: none;
  44. }
  45. /* Position the "next button" to the right */
  46. .next {
  47. right: 0;
  48. }
  49. /* On hover, add a black background color with a little bit see-through */
  50. .prev:hover,
  51. .next:hover {
  52. background-color: rgba(0, 0, 0, 0.8);
  53. }
  54. /* Caption text */
  55. .text {
  56. color: #f2f2f2;
  57. font-size: 15px;
  58. padding: 5px 10px;
  59. position: absolute;
  60. bottom: 0px;
  61. left: 50%;
  62. transform: translate(-50%, 0%);
  63. text-align: center;
  64. border-radius: 20px;
  65. background: rgba(0, 0, 0, 0.5);
  66. }
  67. /* Number text (1/3 etc) */
  68. .numbertext {
  69. color: #f2f2f2;
  70. font-size: 12px;
  71. padding: 5px 10px;
  72. position: absolute;
  73. border-radius: 20px;
  74. background: rgba(0, 0, 0, 0.7);
  75. top: 0;
  76. }
  77. /* The dots/bullets/indicators */
  78. .dot {
  79. cursor: pointer;
  80. height: 15px;
  81. width: 15px;
  82. margin: 0 2px;
  83. background-color: #bbb;
  84. border-radius: 50%;
  85. display: inline-block;
  86. }
  87. .active,
  88. .dot:hover {
  89. background-color: #717171;
  90. }
  91. /* Fading animation */
  92. @keyframes fade {
  93. from {
  94. opacity: 0.4;
  95. }
  96. to {
  97. opacity: 1;
  98. }
  99. }
  100. /* On smaller screens, decrease text size */
  101. @media only screen and (max-width: 512px) {
  102. .prev,
  103. .next,
  104. .text {
  105. font-size: 12px;
  106. }
  107. }

javascript:

  1. let slideIndex = 1;
  2. showSlides(slideIndex);
  3. function plusSlides(n) {
  4. showSlides((slideIndex += n));
  5. }
  6. function showSlides(n) {
  7. let i;
  8. let slides = document.getElementsByClassName("mySlides");
  9. if (n > slides.length) {
  10. slideIndex = 1;
  11. }
  12. if (n < 1) {
  13. slideIndex = slides.length;
  14. }
  15. for (i = 0; i < slides.length; i++) {
  16. slides[i].style.display = "none";
  17. }
  18. slides[slideIndex - 1].style.display = "block";
  19. }

希望能对你有所帮助。

展开查看全部

相关问题