如何创建:引用幻灯片
- Previous Page Block Counter
- Next Page Collapsible List Items
学习如何使用 CSS 和 JavaScript 创建引用幻灯片。
引用幻灯片
创建引用幻灯片
第一步 - 添加 HTML:
一切反动派都是纸老虎!- 毛泽东
</div>改革是中国发展生产力的必由之路。- 邓小平
</div>中国共产党人的初心和使命,就是为中国人民谋幸福,为中华民族谋复兴。- 最高领袖
</div> ❮ <a class="next" onclick="plusSlides(1)">❯</a> </div> /* Dot/Item symbol/Indicator */ <div class="dot-container"> <span class="dot" onclick="currentSlide(1)"></span> <span class="dot" onclick="currentSlide(2)"></span> <span class="dot" onclick="currentSlide(3)"></span> </div>Step 2 - Add CSS:
Set the styles for the slides, buttons, dots, etc.:
/* Slideshow container */ .slideshow-container { position: relative; background: #f1f1f1f1; } /* Slides */ .mySlides { display: none; padding: 80px; text-align: center; } /* Next & Previous buttons */ .prev, .next { cursor: pointer; position: absolute; top: 50%; width: auto; margin-top: -30px; padding: 16px; color: #888; font-weight: bold; font-size: 20px; border-radius: 0 3px 3px 0; user-select: none; } /* Position the 'next button' to the right */ .next { position: absolute; right: 0; border-radius: 3px 0 0 3px; } /* Add a semi-transparent black background color when the mouse hovers */ .prev:hover, .next:hover { background-color: rgba(0,0,0,0.8); color: white; } /* Dot/Item symbol/Indicator container */ .dot-container { text-align: center; padding: 20px; background: #ddd; } /* Dot/Item symbol/Indicator */ .dot { cursor: pointer; height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } /* Add background color for the active dot/circle */ .active, .dot:hover { background-color: #717171; } /* Add italic style for all quotes */ q {font-style: italic;} /* Add blue color for the author */ .author {color: cornflowerblue;}Step 3 - Add JavaScript:
var slideIndex = 1; showSlides(slideIndex); function plusSlides(n) { showSlides(slideIndex += n); } function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; }Relevant pages
Tutorial:How to Create Image Slides
Tutorial:How to Create Lightbox
- Previous Page Block Counter
- Next Page Collapsible List Items
Toolbox
JavaScript and HTML DOM Reference Manual
JavaScript Examples
JavaScript Quiz
Advanced JavaScript Tutorial
Sponsor Links
The content provided by CodeW3C.com is for training and testing purposes only and does not guarantee the accuracy of the content. Risks associated with the use of this site's content are not related to this site. All rights reserved.
About CodeW3C.com Help for CodeW3C.com Terms of Use Privacy Terms
![]()
![]()