Slide Schow mit festem Hintergrundbild

Hallo Experten, wie kann ich bei einer Slideshow (siehe Code) ein bestimmtes Hintergrundbild genau hinter den anderen Bildern der Slideshow einbauen und dabei auch die Transparenz des Bildes im Code festlegen? Habe leider zu meinem Problem leider nichts Passendes gefunden, was ein Anfänger auf Anhieb versteht... Sorry, ich bin ein kompletter Neuling in HTML / Javascript. Vielen Dank bereits im Voraus für eure Tipps bzw. Hilfsbereitschaft!

Der hier verwendete Code

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * {box-sizing: border-box;} body {font-family: Verdana, sans-serif;} .mySlides {display: none;} img {vertical-align: middle;} .slideshow-container { max-width: 1000px; position: relative; margin: auto; } .slideshow-container:after{ content : ""; display: block; position: absolute; top: 0; left: 0; background-image:url('http://sebastian1012.bplaced.net/bilder/2.jpg'); width: 100%; height: 100%; background-size:cover; background-repeat:no-repeat; opacity : 0.5; z-index: -1; filter: grayscale(0.75); filter: hue-rotate(270deg); } .text { color: #f2f2f2; font-size: 15px; padding: 8px 12px; position: absolute; bottom: 8px; width: 100%; text-align: center; } .numbertext { color: #f2f2f2; font-size: 12px; padding: 8px 12px; position: absolute; top: 0; } .dot { height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } .active { background-color: #717171; } .fade { animation-name: fade; animation-duration: 1.5s; } @keyframes fade { from {opacity: .0} to {opacity: 1} } /* On smaller screens, decrease text size */ @media only screen and (max-width: 300px) { .text {font-size: 11px} } </style> </head> <body> <h2>Automatic Slideshow</h2> <p>Change image every 2 seconds:</p> <div class="slideshow-container"> <div class="mySlides fade"> <div class="numbertext">1 / 3</div> <img src="https://www.w3schools.com/howto/img_nature_wide.jpg" style="width:100%"> <div class="text">Caption Text</div> </div> <div class="mySlides fade"> <div class="numbertext">2 / 3</div> <img src="https://www.w3schools.com/howto/img_snow_wide.jpg" style="width:100%"> <div class="text">Caption Two</div> </div> <div class="mySlides fade"> <div class="numbertext">3 / 3</div> <img src="https://www.w3schools.com/howto/img_mountains_wide.jpg" style="width:100%"> <div class="text">Caption Three</div> </div> </div> <br> <div style="text-align:center"> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> </div> <script> var slideIndex = 0; showSlides(); function showSlides() { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } slideIndex++; if (slideIndex > slides.length) {slideIndex = 1} 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"; setTimeout(showSlides, 2000); // Change image every 2 seconds } </script> </body> </html>

Add Comment

* Required information
1000
Drag & drop images (max 3)
Powered by Commentics

Comments

No comments yet. Be the first!