How can I incorporate a slideshow into HTML?

728 views Asked by At

I would like to know if you could guide me on making a slideshow for my HTML document. I know that I will need JavaScript, and I already know how to MAKE the slideshow, but how would I make the slideshow able for view in my html document? Here is the code, and I am using Adobe Brackets as an editor:

//////HTML CODE ////////

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="main.css" type="text/css">
        <title>Quentrum</title>
    </head>
    <body>
        <div id="wrapper">
        <header>
              <nav>
                <ul>
                    <li>
                        <a href="index.html">
                        Quentrum
                        </a>
                    </li>
                    <li>
                         <a href="Store.html">
                        Store
                        </a>
                    </li>
                    <li>
                         <a href="Support.html">
                        Support
                        </a>
                    </li>

                </ul>
                </nav>
            </header>
            <section>
                <h>----------Slideshow Goes HERE-----------</h>
            </section>
            <footer>
             <p>Quentrum 2015</p>
            </footer>
        </div>
    </body>
</html>

//////// CSS CODE /////////

body{
background-color:lightgray;
}
#wrapper{
width:inherit;
}
header{
background-color: white;
clear:both;
height: 50px;
border:solid 1px black;
border-radius: 5px;
width: inherit;
padding-right:195px;
padding-left:195px;
}

header ul {
list-style: none;
}
header ul li{
display: inline;
padding: 115px;
}
header a {
color: #777;
text-decoration: none;
font-family: Georgia;
font-size: 17px;
}
header a hover:{
color:black;
}
section{
clear: both;
height: 550px;
width: 100%;
border: solid 1px darkblue;
border-radius: 5px;
background: blue;
font-family: Georgia;
}
footer{
width: 100%;
border: solid 1px gray;
border-radius: 5px;
background: lightgray;
clear: both;
}
footer p {
font-family: Geogria;
margin-left: 30px;
}

Thank you in advance!!!

EDIT[I don't think I really need to paste any Javascript code, but please TELL me if you need it, and I'll get it up. For the sake of this when you answer, you can just pretend that the name of my javascript file is "example" Many thanks.]

5

There are 5 answers

6
RicPurcell On BEST ANSWER

Hope this helps extremely simple simply add this code where you want it then there is no left and right links to next n prev if want images same size simply change image size read notes/ comments for further details

<!-- Add below This To HEAD -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<!-- Add below  this to your style sheet -->
  .carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
      width: 70%;
      margin: auto;
  }

<!-- Add Below this where you want it in your page -->
<div class="container">
  <br>
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
      <li data-target="#myCarousel" data-slide-to="3"></li>

<!-- 
Add 
<li data-target="#myCarousel" data-slide-to="next number"></li>
to how many images you want or if you dont want any links to change images atall delete this up to indicators
-->     
      
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="firstimg.jpg" alt="Chania" width="460" height="345">
      </div>

      <div class="item">
        <img src="secondimg.jpg" alt="Chania" width="460" height="345">
      </div>
    
      <div class="item">
        <img src="thirdimage.jpg" alt="Flower" width="460" height="345">
      </div>

      <div class="item">
        <img src="fourthimage.jpg" alt="Flower" width="460" height="345">
        
<!-- Add for more images
<div class="item">
        <img src="nextimage.jpg" alt="..." width="460" height="345">
        
If want captions Add like so

<img src="filename.jpg" alt="alt">
      <div class="carousel-caption">
        <h3>Title</h3>
        <p>Caption</p>
      </div>
    </div>

        -->
       
      </div>
    </div>
  </div>
</div>

0
repo On

This might not be the way you want to do it, however there is a built in Bootstrap slideshow option.

Its called a carousel, here is the link for a tutorial: http://www.w3schools.com/bootstrap/bootstrap_carousel.asp

2
RicPurcell On

What kind of slideshow are you looking forI am currently create one using jquery and php

a preview of the slideshow can be found at http://rbgraphix.co.uk/gallery/display/New/slideshow.php

at the moment it is not automatic but I am in the process of making it this way and also has an upload page /upload.php and a delete page (currently in coding (for admin users)

2
Geoffrey On

You can do it via jQuery.

        $(function () {

            $("#slideshow > div:gt(0)").hide();

            setInterval(function () {
                $('#slideshow > div:first')
                        .fadeOut(1000)
                        .next()
                        .fadeIn(1000)
                        .end()
                        .appendTo('#slideshow');
            }, 3000);

        });

Example: JSFiddle

7
RicPurcell On

i have resolved the footer and navigation issue for you I believe simply download this new css file and replace it with current bootstrap.css

Link to Bootstrap CSS Click To Download Check your css as I noticed it says lightgray not lightgrey

also add this to your current main.css

footer p {
font-family: Geogria;
margin-left:30px;
font-size:16px; /* Font Size You Want */
}

and regarding you background color change it to lightgrey and should work ok once done these steps