0

I had to put my background-image CSS code for my header in my HTML because it didn't work in the CSS file alone for some reason but anyways Ive been trying all these different ways to make a slideshow but nothing is working can someone help guide me? Btw I have 4 Banner images that are all called banner1, banner2 ,banner3, banner4.jpg and are located in my IMAGES/banner1.jpg folder.

$(document).ready(function(){
  // Add smooth scrolling to all links
  $("a").on('click', function(event) {

    // Make sure this.hash has a value before overriding default behavior
    if (this.hash !== "") {
      // Prevent default anchor click behavior
      event.preventDefault();

      // Store hash
      var hash = this.hash;

      // Using jQuery's animate() method to add smooth page scroll
      // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
      $('html, body').animate({
        scrollTop: $(hash).offset().top
      }, 800, function(){
   
        // Add hash (#) to URL when done scrolling (default click behavior)
        window.location.hash = hash;
      });
    } // End if
  });  
});
body
{
 background-color: #808080;

}
p
{
 !-- 
}
p.homeclassheader
{
 font-weight: bold;
 font-size: 35px;
 font-family: Tahoma, Geneva, sans-serif;
 line-height: 150%;
 text-align: center;
 color: white;
 text-shadow: 2px 2px 3px grey;
 word-spacing: 3px;
 letter-spacing: -1;
 font-variant: small-caps;
}
header
{
 text-align:center;
 text-shadow: 2px 2px 3px grey;
 color: silver;  
 padding: 20px 0px 0px 0px;
 border-bottom: #808080;
 position: fixed;
 border-bottom: 2px solid #00FFF5;
 top: -10;
 height: 150px;
 left: -10;
 width: 105%;
 z-index:5;
}  
header a
{
 text-decoration: none;
 text-align:center;
 text-shadow: 2px 2px 5px grey;
 font-weight: bold;
 font-size: 40px;
 font-family: Tahoma, Geneva, sans-serif;
 line-height: 100%;
 color: white;
 word-spacing: 3px;
 letter-spacing: -1;
 font-variant: small-caps;

}
hr {
    border: 0;
    height: 2px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
header a:visited
{
 text-decoration: none;
 text-align:center;
 text-shadow: 2px 2px 3px grey;
 color: silver;  

}
article
{

}
article.homeclass
{
 text-align:center;
 color: silver;   
 padding: 0px 20px 0px 20px;
    background-color: #393E46;
 border-bottom: 2px solid #00FFF5;
 border-top: 2px solid #00FFF5;
 height: 350px;
 float: left;
 width: 75%;
 max-width: 350px;
 margin: 0 auto;
}
article.homeclass img
{ 
 float: right;
 margin-left: 30px;
 margin-right: 25px;
 margin-top: -15px;
 margin-bottom: 0px;
}
ul.menu {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
 font-weight: bold;
 font-size: 15px;
 font-family: "Comic Sans MS", cursive, sans-serif;
    background-color: #393E46;
 position: fixed;
 top: 180;
 width:99%;
 z-index:5;

}

ul.menu li {
    float: left;
}

ul.menu li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
 border-bottom: 2px solid #00FFF5;
    -moz-transition: background-color .3s ease-in;
 -webkit-transition: background-color .3s ease-in;
 -o-transition: background-color .3s ease-in;
 transition: background-color .3s ease-in;
}

ul.menu li a:hover {
    background-color: #00ADB5;
    color: black;
 -moz-transition: background-color 0.01s;
 -webkit-transition: background-color 0.01s;
 -o-transition: background-color 0.01s;
 transition: background-color 0.01s;
}

a:visited
{
 text-decoration: none;
}

a:link
a:focus
a:hover
a:active
footer a
{
 text-decoration: none;
 text-align:center;
 color: #00FFF5; 
}
footer
{
 text-align:center;
 color: silver;  
    background-color: #393E46;
 padding: 10px 0px 0px 0px;
 border-bottom: #808080;
 position: absolute;
 bottom: 0px;
 height: 25px;
 border-top: 2px solid #00FFF5;
 width: 105%;
}
<HTML>
 <HEAD>
  <LINK rel="stylesheet" type="text/css" href="CSS/styles.css">
  <TITLE>Las Vegas | Home</TITLE>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="JAVASCRIPT/scrolleffect.js"></script>

 </HEAD>
 <BODY>
  <HEADER>
  <style>
  header {
   background-image: url("IMAGES/banner1.jpg");
  }
  </style>
   <a name="top"><H1>Las Vegas</H1></A>
  </HEADER>
  <div id="home"></div>
  <br>
  <br><br><br><br><br><br><hr><br><br>
  <br>
  <ARTICLE class="homeclass">
  <p class="homeclassheader">Accommodation</p>
  <hr>
  <p class="class2">Hotel 1</p>
  <p class="class2">Hotel 2</p>
  <p class="class2">Hotel 3</p>
  <hr>
  </ARTICLE>
  <br><br><br><br><br><br>
  <FOOTER>
   <NAV>
    All Copyright reserved to Dylan 2017 &copy;<br>
   </NAV>
  </FOOTER>
 
 </BODY>
</HTML>
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
Dylan5993
  • 11
  • 1
  • 3
  • Welcome to StackOverflow! You don't actually have any code that would create a slideshow with the banner as it stands. Have you attempted to create the slideshow? Have you looked into using any plugins to handle that for you? If you don't want to use a plugin, you'll also need to let us know things like how long the delay should be, and how the slideshow should be 'triggered'. – Obsidian Age Mar 13 '17 at 02:53
  • See [Trying to make multiple background images cycle through a slideshow with CSS and JQUERY](http://stackoverflow.com/questions/30388118/trying-to-make-multiple-background-images-cycle-through-a-slideshow-with-css-and/) – guest271314 Mar 13 '17 at 02:56
  • Hey yes i know I've tried to implement code for a slideshow although it hasnt worked so i removed it. I was just wandering if someone could have a go at making it work then show me using the way i used to add my background-image. The delay doesnt have to be long 5 seconds before the image changes, fading between images would be nice? Any Help? – Dylan5993 Mar 13 '17 at 03:48

1 Answers1

0

This code shows how you would create a basic slide show in your webpage it is important to remember to link to also take into consideration the src of your image if it is coming from an images folder then you have to reference that properly. src="./images/lifeofpi.jpg" For example it is taking the image lifeofpi.jpg from the folder of images. And make sure the <link rel>is placed in the head of your website. (automatic slideshow)

<!DOCTYPE html>
<html>
<title>Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/html/styles.css">
<style>
.mySlides {display:none;}
</style>
<body>

<h2 class="w3-center">Automatic Slideshow</h2>

<div class="w3-content w3-section" style="max-width:500px">
<img class="mySlides" src="img_la.jpg" style="width:100%">
<img class="mySlides" src="img_ny.jpg" style="width:100%">
<img class="mySlides" src="img_chicago.jpg" style="width:100%">
</div>  

<script>
var myIndex = 0;
carousel();

function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
   x[i].style.display = "none";  
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}    
x[myIndex-1].style.display = "block";  
setTimeout(carousel, 5000); // Change image every 5 seconds
}
</script>

</body>
</html>
cars
  • 318
  • 3
  • 11
  • Thanks for the response! Although this is manual slideshow, how would i make this an automatic slideshow with embedded CSS code in my HTML file. – Dylan5993 Mar 13 '17 at 03:50
  • If you want to add css into a html file you just have to use the – cars Mar 13 '17 at 03:57
  • Yes i know, although i cant use the tags to add all my images in as i can only use the background-image option to make my image show behind my text and everything. So im not sure how to do add more images and make it a slideshow using embedded css and using background-image??? – Dylan5993 Mar 14 '17 at 04:06
  • The code above shows you how to create a automatic slideshow. You can literally copy and past the code in my answer and just change the file location of the image for example src="./images/lifeofpi.jpg". what this src means is that it is taking the lifeofpi.jpg from the images folder – cars Mar 14 '17 at 07:06