/    Sign up×
Community /Pin to ProfileBookmark

Need help with a gallery with a slideshow in a new window

Hi,

I’m trying to create a website with a gallery with lots of small images next to each other (such as Pinterest) and when you click on the images a new overlay window will pop up with a slideshow. I have LOTS of problems and I would really appreciate some help:

  • 1.

    How should I create a gallery? At the moment my images are just below each other and in their original sizes. What I’m looking for is to create small images which will expand when you click on them. To do this I guess I’ll need to use thumbnails but I can’t seem to find any instructions how to do it.

  • 2.

    I’ve created the function (or well, not a real function in JS, just in the html code) where a new overlay window opens when you click on an image but at the moment it’s just a white box appearing. How should I do to get the slideshow in there?

  • HTML:

    [code]
    <!DOCTYPE HTML>
    <html>
    <head>

    <link href=”‘http://fonts.googleapis.com/css?family=Montserrat’ rel=stylesheet’ type=’text/css’>”
    <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
    <script type=”text/javascript” src=”JavaScript-2.js”></script>
    <link rel=”stylesheet” type=”text/css” href=”CSS-2.css”>

    <title></title>
    </head>

    <body>
    <a href=”javascript:void(0)” onclick=”document.getElementById(‘light’).style.display=’block’;document.getElementById(‘fade’).style.display=’block'”></a>
    <div id=”light” class=”white_content”>
    <a href=”javascript:void(0)” onclick=”document.getElementById(‘light’).style.display=’none’;document.getElementById(‘fade’).style.display=’none'” class=”textright”>Close</a>

    </div>
    <div id=”fade” class=”black_overlay”></div>

    <div id=”sidhuvud”>
    <br><a href=”HTML-3.html”><img src=”logo.jpg” width=”380″ height=”62″ alt=”logo”></a>
    </div>
    <ul id=”navbar”>
    <li><a href=”about.htm”>CONTACT</a>
    <ul>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    </ul>
    </li>
    <li><a href=”inspiration.htm”>INSPIRATION</a>
    <ul>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>
    </ul>
    </li>
    <li><a href=”art.htm”>PORTFOLIO</a>
    <ul>
    <li><a href=”#”>Underrubrik</a></li>

    </ul>
    <li><a href=”press.htm”>HEJ</a>
    <ul>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>

    </ul>
    <li><a href=”contact.htm”>ABOUT</a>
    <ul>
    <li><a href=”#”>Underrubrik</a></li>
    <li><a href=”#”>Underrubrik</a></li>

    </ul>
    </ul>

    </div>

    <div class=”container”>
    <div class=”slider_wrapper”>
    <ul id=”image_slider”>

    <ul>
    <img li src=”pics/1gif.jpg” onmouseover=”toggleImage(this, 0);” onmouseout=”toggleImage(this, 1);” a href=”javascript:void(0)” onclick=”document.getElementById(‘light’).style.display=’block’;document.getElementById(‘fade’).style.display=’block'”></a>
    <img li src=”pics/2gif.jpg” onmouseover=”toggleImage(this, 0);” onmouseout=”toggleImage(this, 1);” a href=”javascript:void(0)” onclick=”document.getElementById(‘light’).style.display=’block’;document.getElementById(‘fade’).style.display=’block'”></a>
    <img li src=”pics/3gif.jpg” onmouseover=”toggleImage(this, 0);” onmouseout=”toggleImage(this, 1);” a href=”javascript:void(0)” onclick=”document.getElementById(‘light’).style.display=’block’;document.getElementById(‘fade’).style.display=’block'”></a>

    </ul></li>

    <span class=”nvgt” id=”prev”></span>
    <span class=”nvgt” id=”next”></span>
    </div>
    </div>
    </div>
    </div>
    </body>
    </html>
    [/code]

    JS:

    [code]//1. set ul width
    //2. image when click prev/next button
    var ul;
    var li_items;
    var imageNumber;
    var imageWidth;
    var prev, next;
    var currentPostion = 0;
    var currentImage = 0;
    var ThumbScale=0.2;
    var ImgScale=1.05;

    function init(){
    slideShow()
    slideShow = document.getElementById(“white_content”);
    onclick = slideShow;
    toggleImage()
    ul = document.getElementById(‘image_slider’);
    li_items = ul.children;
    imageNumber = li_items.length;
    imageWidth = li_items[0].children[0].clientWidth;
    ul.style.width = parseInt(imageWidth * imageNumber) + ‘px’;
    prev = document.getElementById(“prev”);
    next = document.getElementById(“next”);
    //.onclick = slide(-1) will be fired when onload;
    /*
    prev.onclick = function(){slide(-1);};
    next.onclick = function(){slide(1);};*/
    prev.onclick = function(){ onClickPrev();};
    next.onclick = function(){ onClickNext();};
    }
    window.onload = init;

    function slideShow(opts){
    var start = new Date;
    var id = setInterval(function(){
    var timePassed = new Date – start;
    var progress = timePassed / opts.duration;
    if (progress > 1){
    progress = 1;
    }
    var delta = opts.delta(progress);
    opts.step(delta);
    if (progress == 1){
    clearInterval(id);
    opts.callback();
    }
    }, opts.delay || 17);
    //return id;
    }

    function slideTo(imageToGo){
    var direction;
    var numOfImageToGo = Math.abs(imageToGo – currentImage);
    // slide toward left

    direction = currentImage > imageToGo ? 1 : -1;
    currentPostion = -1 * currentImage * imageWidth;
    var opts = {
    duration:1000,
    delta:function(p){return p;},
    step:function(delta){
    ul.style.left = parseInt(currentPostion + direction * delta * imageWidth * numOfImageToGo) + ‘px’;
    },
    callback:function(){currentImage = imageToGo;}
    };
    slideShow(opts);
    }

    function onClickPrev(){
    if (currentImage == 0){
    slideTo(imageNumber – 1);
    }
    else{
    slideTo(currentImage – 1);
    }
    }

    function onClickNext(){
    if (currentImage == imageNumber – 1){
    slideTo(0);
    }
    else{
    slideTo(currentImage + 1);
    }
    }

    function toggleImage(imageElement, sel){
    if(sel == 0){
    imageElement.style.opacity = 0.7;
    imageElement.filters.alpha.opacity = 100;
    }else{
    imageElement.style.opacity = 1;
    imageElement.filters.alpha.opacity = 40;
    }
    }

    [/code]

    CSS:

    [code]#sidhuvud {padding: 4px; width: 400px; height: 60px; background: #FFFFFF; font-size: 50px;}
    body {
    min-width: 870px;
    max-width: 870px;
    margin: 0;
    padding: 0;
    }

    #box1 {
    background: #000000;
    height: 470px;
    width: 500px;

    padding: 20px;
    margin: 0 auto 0 auto;
    }

    #box {
    width: auto;
    background: #FFFFFF;
    float: left;
    }

    #box2 {
    width: 450px;
    float: left;
    padding: 50px;

    }

    #box3 {
    width: 200px;
    float: left;
    padding: 30px;
    font-size: small;
    font-family: helvetica;
    }

    #navbar {
    margin: 0px;
    padding: 0px;
    left: 0px;
    height:80px; }
    #navbar li {
    list-style: none;
    float: right; } /* Ändra till right om du vill ha menyn till höger istället*/
    #navbar li a {
    display: block;
    padding: 7px 21px 10px 10px;
    background-color: #ffffff; /*Ändra färgen på menyflikarna här*/
    color: #000000; /*Ändra färgen på texten här*/
    text-decoration: none;
    font-family: ‘Montserrat’, sans-serif;
    font-size: 12px; } /*Ändra storleken på texten här*/
    #navbar li ul {
    display: none;
    width: 8em; /* Ändra bredden på undermenyn här */
    background-color: #cccccc;
    /* opacitet for IE */

    /* opacity: 0.80; filter: alpha(opacity=80); */
    /* opacitet CSS3 standard */
    opacity:0.80;
    /* opacitet for Mozilla */
    -moz-opacity:0.80;
    }
    #navbar li:hover ul, #navbar li.hover ul {
    display: block;
    position: absolute;
    margin: 0;
    padding: 0;
    z-index: 1; }
    #navbar li:hover li, #navbar li.hover li {
    float: none; }
    #navbar li:hover li a, #navbar li.hover li a {
    background-color: #ffffff; /*Ändra färgen på undermenyn*/
    border-bottom: 1px solid #fff;
    color: #000000; } /*ändra textfärgen på undermenyn här*/
    #navbar li li a:hover {
    background-color: #ffffff;
    color: #cccccc;
    } /*Ändra färgen när man håller musen över undermenyn*/

    .black_overlay {
    display: none;
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:1001;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
    }
    .white_content {
    display: none;
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    padding: 16px;
    border: 5px solid black;
    background: white;
    z-index:1002;
    overflow: auto;
    }
    .textright {
    float: right;
    }

    .container{
    width:800px;
    height:400px;
    padding:20px;
    border:0px transparent;
    -webkit-box-sizing:content-box;
    -moz-box-sizing:content-box;
    box-sizing:content-box;
    background: transparent;

    }

    .photo{
    width:30%;
    height:30%;
    border:10px white;
    display: inline-block

    }

    .slider_wrapper{
    overflow: hidden;
    position:relative;
    height:relative;
    top:auto;
    }

    #image_slider{

    position: relative;
    height: auto;
    list-style: none;
    overflow: hidden;
    float: left;
    /*Chrom default padding for ul is 40px */
    padding:0px;
    margin:0px;
    }
    #image_slider li{
    position: relative;
    float: left;
    }
    .nvgt{
    position: absolute;
    top: 120px;
    height: 50px;
    width: 30px;
    opacity: 0.6;
    }
    .nvgt:hover{
    opacity: 0.9;

    }
    #prev{
    background: #000 url(‘https://dl.dropboxusercontent.com/u/65639888/image/prev.png’) no-repeat center;
    left: 0px;
    }
    #next{
    background: #000 url(‘https://dl.dropboxusercontent.com/u/65639888/image/next.png’) no-repeat center;
    right: 0px;
    }[/code]

    to post a comment
    JavaScript

    15 Comments(s)

    Copy linkTweet thisAlerts:
    @SempervivumAug 04.2015 — I recommend to use a ready-to-use lightbox plugin. There are many but not many that feature an automatic slideshow:

    http://projects.nickstakenburg.com/lightview

    http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/

    http://highslide.com/

    At the moment my images are just below each other[/QUOTE]
    Your HTML is not correct:
    [code=html] <ul id="image_slider">



    <ul>
    <img li src="pics/1gif.jpg" onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"></a>
    <img li src="pics/2gif.jpg" onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"></a>
    <img li src="pics/3gif.jpg" onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"></a>


    </ul></li>[/code]

    Two opening ul, but only one closing; img-Tag inside ul; li inside img-Tag. Don't use a list for your gallery but place the img-Tags one after each other, then the images will be placed one beside each other.

    in their original sizes. What I'm looking for is to create small images[/QUOTE]There are two ways to do this:
    [LIST=1]
  • [*]Use an image processing software and resize your images to small size.

  • [*]Use CSS to resize your images to small size:

  • [/LIST]

    [code=html]<img src="yourimage.jpg" style="width: yoursmallwidthpx; height: yoursmallheightpx;">[/code]
    Copy linkTweet thisAlerts:
    @agliauthorAug 10.2015 — Fantastic, thank you so much!! Do you have any idea how I should get the slideshow into the popup window? It's for a school project so unfortunately I'm not aloud to use lightbox...
    Copy linkTweet thisAlerts:
    @SempervivumAug 10.2015 — I do not recommend to use a real popup window (window.open) as this might be blocked by the browser. Use a div container and hide it first. On click on a thumbnail enter the image into the container, make it visible and start the slideshow.
    Copy linkTweet thisAlerts:
    @agliauthorAug 11.2015 — Thanks for the respond! I haven't used a window.open though... The pop up (or well, it's not a real pop up window, it's more like a white box and when it's open the rest of the sites turns black/transparent) and it's just written in the HTML code:

    <i>
    </i>&lt;a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;&lt;/a&gt;
    &lt;div id="light" class="white_content"&gt;
    &lt;a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'" class="textright"&gt;X&lt;/a&gt;

    &lt;/div&gt;
    &lt;div id="fade" class="black_overlay"&gt;&lt;/div&gt;


    I'm not sure how to move from here but perhaps I should make this "pop up" thing a real function in JS and then, in some way, place the slideshow in there. Do you have any suggestions?
    Copy linkTweet thisAlerts:
    @SempervivumAug 11.2015 — As far as I can see, your "popup" is quite OK.in some way, place the slideshow in there[/QUOTE]I don't know wether the code in you first posting is still up-to-date. Obviously your slideshow displays the images in the container that has the class "white_content". Unfortunately you try to determine this element by using getElementById("white_content"). If you do this you should not use the class but the ID instead. Fix this, maybe the slideshow is working then.
    Copy linkTweet thisAlerts:
    @agliauthorAug 11.2015 — Hm, that was a good thought! Tried it though and it didn't work, unfortunately... The white_content box just disappeared instead. Any other ideas? When I click the images it's just a white box that pops up, any suggestion how to show the images instead? The code I sent is quite up to date, moved on with another area in between.
    Copy linkTweet thisAlerts:
    @SempervivumAug 11.2015 — Have a look at this:
    [CODE]function init(){
    slideShow()
    slideShow = document.getElementById("white_content");
    onclick = slideShow;[/CODE]

    Do not use the same name for a variable and a function. onclick requires an element to which it is applied.

    And please explain what you intend to do here:
    [CODE] var start = new Date;
    var id = setInterval(function(){
    var timePassed = new Date - start;
    var progress = timePassed / opts.duration;
    if (progress > 1){
    progress = 1;
    }
    var delta = opts.delta(progress);
    opts.step(delta);
    if (progress == 1){
    clearInterval(id);
    opts.callback();
    }
    }, opts.delay || 17);[/CODE]
    Copy linkTweet thisAlerts:
    @agliauthorAug 11.2015 — Ok, I'm not sure if I get you exactly but I've done like this now:

    function init(){
    slideShow()
    onclick = document.getElementById('image_slider');
    toggleImage()


    Regarding the SlideShow function I don't really know what I intend to do... I've been searching all over internet for different slideshows and perhaps this is something I forgot to delete from an unuseful slideshow... This seems to be some sort of automatic slideshow which change image depending on time but the only function I need is really to move from one image to another. Perhaps this function is enough then:

    function onClickPrev(){
    if (currentImage == 0){
    slideTo(imageNumber - 1);
    }
    else{
    slideTo(currentImage - 1);
    }
    }

    function onClickNext(){
    if (currentImage == imageNumber - 1){
    slideTo(0);
    }
    else{
    slideTo(currentImage + 1);
    }
    }
    Copy linkTweet thisAlerts:
    @SempervivumAug 12.2015 — Regarding the SlideShow function I don't really know what I intend to do... I've been searching all over internet for different slideshows and perhaps this is something I forgot to delete from an unuseful slideshow[/QUOTE]Apparently you copied code from the web without understandig it. Maybe it would be better if you read a tutorial for creating a slideshow. Google finds several ones, e. g. this one:

    http://www.javascriptkit.com/howto/show.shtml

    and this:

    https://coderwall.com/p/vsdrug/how-to-create-an-image-slider-with-javascript
    Copy linkTweet thisAlerts:
    @agliauthorAug 12.2015 — Yes, guilty. Big thanks for the tutorial, the last one was for the slideshow I already had but now I understand all the areas (I think) and I have modified it a bit. But still, how am I supposed to get it into the white pop up box? This is so frustrating cause I don't even know where to begin!
    Copy linkTweet thisAlerts:
    @SempervivumAug 12.2015 — Did you clean up your code and leave only what is required for that slideshow? Then post the code again und we will find out what to do.
    Copy linkTweet thisAlerts:
    @agliauthorAug 12.2015 — I've cleaned up the js code now and the slideshow seems to be working. At the moment it's located at the entire page so the "next and prev" buttons are visible on the sides. How on earth should I get them into the white_content box? This "pop up" function is not even a real function, perhaps I need to do it all in JS instead of HTML?

    In the HTML I've now made an ul with all the images for the slideshow but I need to connect them to the "real" images from the gallery to make sure right image pops up when clicking. Perhaps I should work with parameters here?

    Well, I'm really stuck and if you have any suggestions that would be amazing!

    HTML:
    &lt;!DOCTYPE HTML&gt;
    &lt;html&gt;
    &lt;head&gt;

    &lt;link href="'http://fonts.googleapis.com/css?family=Montserrat' rel=stylesheet' type='text/css'&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;script type="text/javascript" src="JavaScript-2.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" type="text/css" href="CSS-2.css"&gt;

    <i> </i>&lt;title&gt;A&lt;/title&gt;
    &lt;/head&gt;


    &lt;body&gt;
    &lt;a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;&lt;/a&gt;
    &lt;div id="light" class="white_content"&gt;
    &lt;a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'" class="textright"&gt;X&lt;/a&gt;

    &lt;/div&gt;
    &lt;div id="fade" class="black_overlay"&gt;&lt;/div&gt;


    &lt;div id="header"&gt;
    &lt;br&gt;&lt;a href="HTML-3.html"&gt;&lt;img src="pics/logo.jpg" width="380" height="62" alt="logo"&gt;&lt;/a&gt;
    &lt;/div&gt;
    &lt;div id="body"&gt;
    &lt;ul id="navbar"&gt;
    &lt;li&gt;&lt;a href="contact.htm"&gt;CONTACT&lt;/a&gt;

    <i> </i>&lt;li&gt;&lt;a href="instagram.htm"&gt;SOCIAL MEDIA&lt;/a&gt;
    <i> </i>&lt;ul&gt;
    &lt;li&gt;&lt;a href="instagram.htm"&gt;Instagram&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="pinterest.htm"&gt;Pinterest&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;

    &lt;/li&gt;
    &lt;li&gt;&lt;a href="inspiration.htm"&gt;INSPIRATION&lt;/a&gt;
    &lt;ul&gt;
    &lt;li&gt;&lt;a href="#"&gt;Inspiration&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Sketches&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Pinterest&lt;/a&gt;&lt;/li&gt;

    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="portfolio.htm"&gt;PORTFOLIO&lt;/a&gt;
    &lt;ul&gt;
    &lt;li&gt;&lt;a href="#"&gt;All&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Art&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Interior&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Fashion&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Illustration&lt;/a&gt;&lt;/li&gt;


    &lt;/ul&gt;


    &lt;li&gt;&lt;a href="about.htm"&gt;ABOUT&lt;/a&gt;

    &lt;/ul&gt;


    <i> </i>&lt;img alt src="pics/1gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;
    <i> </i>&lt;img alt src="pics/2gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;
    <i> </i>&lt;img alt src="pics/3gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;
    <i> </i> &lt;img alt src="pics/5gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;
    <i> </i> &lt;img alt src="pics/1gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;
    <i> </i> &lt;img alt src="pics/4gif.jpg" class='photo' onmouseover="toggleImage(this, 0);" onmouseout="toggleImage(this, 1);" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'"&gt;


    <i> </i>&lt;div class="white_content"&gt;
    <i> </i> &lt;div class="image-slider-wrapper"&gt;
    <i> </i>&lt;ul id="image_slider"&gt;



    <i> </i> &lt;li&gt;&lt;img alt src="pics/1gif.jpg"&gt;&lt;/li&gt;
    <i> </i>&lt;li&gt;&lt;img alt src="pics/2gif.jpg"&gt;&lt;/li&gt;
    <i> </i>&lt;li&gt;&lt;img alt src="pics/3gif.jpg"&gt;&lt;/li&gt;
    <i> </i> &lt;li&gt;&lt;img alt src="pics/5gif.jpg"&gt;&lt;/li&gt;
    <i> </i> &lt;li&gt;&lt;img alt src="pics/1gif.jpg"&gt;&lt;/li&gt;

    <i> </i> &lt;/ul&gt;
    <i> </i> &lt;/div&gt;
    <i> </i> &lt;/div&gt;

    <i> </i> &lt;/div&gt;
    <i> </i> &lt;/div&gt;





    <i> </i> &lt;span class="nvgt" id="prev"&gt;&lt;/span&gt;
    <i> </i> &lt;span class="nvgt" id="next"&gt;&lt;/span&gt;

    &lt;/div&gt;
    &lt;/body&gt;
    &lt;/html&gt;


    CSS:

    <i>
    </i>#header {padding: 4px; width: 400px; height: 60px; background: #FFFFFF; font-size: 50px;}
    body {
    min-width: 870px;
    max-width: 870px;
    margin-left: 50px;
    margin-top: -20px;
    padding: 0px;
    }

    #container {
    min-height:100%;
    position:relative;
    }

    #body {
    padding:10px;
    padding-bottom:60px;
    }


    #box1 {
    background: #000000;
    height: 470px;
    width: 500px;
    padding: 20px;
    margin: 0 auto 0 auto;
    }

    #box {
    width: auto;
    background: #FFFFFF;
    float: left;
    }

    #box2 {
    width: 450px;
    float: left;
    padding: 50px;


    }

    #box3 {
    width: 200px;
    float: left;
    padding: 30px;
    font-size: small;
    font-family: helvetica;
    }



    #navbar {
    margin-top: 12px;
    padding: 0px;
    left: 0px;
    height:80px; }
    #navbar li {
    list-style: none;
    float: right; } /*Place the menu to the right*/
    #navbar li a {
    display: block;
    padding: 7px 21px 10px 10px;
    background-color: #ffffff; /*Ändra färgen på menyflikarna här*/
    color: #000000; /*Ändra färgen på texten här*/
    text-decoration: none;
    font-family: 'Montserrat', sans-serif; :'Catamaran', sans-serif;
    font-size: 12px; } /*Ändra storleken på texten här*/
    #navbar li ul {
    display: none;
    width: 8em; /* Ändra bredden på undermenyn här */
    background-color: #cccccc;
    /* opacitet for IE */

    /* opacity: 0.80; filter: alpha(opacity=80); */
    /* opacitet CSS3 standard */
    opacity:0.80;
    /* opacitet for Mozilla */
    -moz-opacity:0.80;
    }
    #navbar li:hover ul, #navbar li.hover ul {
    display: block;
    position: absolute;
    margin: 0;
    padding: 0;
    z-index: 1; }
    #navbar li:hover li, #navbar li.hover li {
    float: none; }
    #navbar li:hover li a, #navbar li.hover li a {
    background-color: #ffffff; /*Ändra färgen på undermenyn*/
    border-bottom: 1px solid #fff;
    color: #000000; } /*ändra textfärgen på undermenyn här*/
    #navbar li li a:hover {
    background-color: #ffffff;
    color: #cccccc;
    } /*Ändra färgen när man håller musen över undermenyn*/

    .black_overlay {
    display: none;
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:1001;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
    }
    .white_content {
    display: none;
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    padding: 16px;
    border: 5px solid black;
    background: white;
    z-index:1002;
    overflow: auto;

    }

    #white_content {
    display: none;
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    padding: 16px;
    border: 5px solid black;
    background: transparent;
    z-index:1002;
    overflow: auto;
    }
    .textright {
    float: right;
    color: #AAAAAA;
    }


    .container{
    width:800px;
    height:400px;
    padding:20px;
    border:0;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    box-sizing:border-box;
    background: transparent;
    }

    .image-slider-wrapper{
    overflow: hidden;
    position: relative;
    height:280px;
    top:auto;
    }

    #image_slider{
    position: relative;
    height: auto;
    list-style: none;
    overflow: hidden;
    float: left;
    padding:0px;
    margin:0px;
    }

    #image_slider li{
    max-width: 100%;
    float:left;
    list-style: none;
    position: relative;
    }

    .photo{
    width: 20%;
    height: 20%;
    margin: 2px;
    display: inline-block;

    }



    .nvgt{
    position: absolute;
    top: 120px;
    height: 50px;
    width: 30px;
    opacity: 0.6;
    }
    .nvgt:hover{
    opacity: 0.9;


    }
    #prev{
    background: #000 url('https://dl.dropboxusercontent.com/u/65639888/image/prev.png') no-repeat center;
    left: 0px;
    }
    #next{
    background: #000 url('https://dl.dropboxusercontent.com/u/65639888/image/next.png') no-repeat center;
    right: 0px;
    }

    #wrapper{

    <i> </i>width:400px;
    <i> </i>margin: auto;
    <i> </i>height: 600px;
    <i> </i>padding: 0px;
    <i> </i>text-align: center;

    }

    #footer {
    position:absolute;
    bottom:0;
    height:60px;
    background:transparent;
    text-align: center;
    min-width:870px;
    max-widht:870px;
    }
    h1 {font-family: link href="'http://fonts.googleapis.com/css?family=Catamaran:100'"; text-decoration: underline; text-align: center; font-size: 50px;}


    Copy linkTweet thisAlerts:
    @agliauthorAug 12.2015 — JS:

    //1. set ul width
    //2. image when click prev/next button
    var ul;
    var liItems;
    var imageNumber;
    var imageWidth;
    var prev, next;
    var currentPostion = 0;
    var currentImage = 0;

    function init(){
    toggleImage()
    ul = document.getElementById('image_slider');
    liItems = ul.children;
    imageNumber = liItems.length;
    imageWidth = liItems[0].children[0].offsetWidth;
    prev.onclick = function(){ onClickPrev();};
    next.onclick = function(){ onClickNext();};

    }

    function slider(ul){
    animate({
    delay:17,
    duration: 3000,
    delta:function(p){return Math.max(0, -1 + 2 * p)},
    step:function(delta){
    ul.style.left = &amp;#8216;-&amp;#8217; + parseInt(currentImage * imageWidth + delta * imageWidth) + &amp;#8216;px&amp;#8217;;
    },
    callback:function(){
    currentImage++;
    if(currentImage &lt; imageNumber-1){
    slider(ul);
    }
    else{
    var leftPosition = (imageNumber - 1) * imageWidth;

    <i> </i> }
    <i> </i> }
    <i> </i>});
    }



    function slideTo(imageToGo){
    var direction;
    var numOfImageToGo = Math.abs(imageToGo - currentImage);

    <i> </i>direction = currentImage &gt; imageToGo ? 1 : -1;
    <i> </i>currentPostion = -1 * currentImage * imageWidth;
    <i> </i>var opts = {
    <i> </i> duration:1000,
    <i> </i> delta:function(p){return p;},
    <i> </i> step:function(delta){
    <i> </i> ul.style.left = parseInt(currentPostion + direction * delta * imageWidth * numOfImageToGo) + 'px';
    <i> </i> },
    <i> </i> callback:function(){currentImage = imageToGo;}
    <i> </i>};
    <i> </i>slideShow(opts);
    }

    function onClickPrev(){
    if (currentImage == 0){
    slideTo(imageNumber - 1);
    }
    else{
    slideTo(currentImage - 1);
    }
    }

    function onClickNext(){
    if (currentImage == imageNumber - 1){
    slideTo(0);
    }
    else{
    slideTo(currentImage + 1);
    }
    }

    function toggleImage(imageElement, sel){
    if(sel == 0){
    imageElement.style.opacity = 0.7;
    imageElement.filters.alpha.opacity = 100;
    }else{
    imageElement.style.opacity = 1;
    imageElement.filters.alpha.opacity = 40;
    }
    }

    window.onload = init;


    Copy linkTweet thisAlerts:
    @SempervivumAug 14.2015 — Hallo agli,

    in your JS some functions were missing. I recommend to use the code from the demo with prev/next button.

    And if you want to run the slideshop in your pop-up container you have to open this container at click on a thumbnail:
    [code=html] <div id="light" class="white_content">
    <span class="nvgt" id="prev"></span>
    <span class="nvgt" id="next"></span>
    <div class="image-slider-wrapper">
    <ul id="image_slider">



    <li><img alt src="images/01.png"></li>
    <li><img alt src="images/02.png"></li>
    <li><img alt src="images/03.png"></li>
    <li><img alt src="images/04.png"></li>

    </ul>
    </div>
    </div>
    [/code]
    In your code id="light" was missing here but present in another container above. And you should place the next/prev buttons in the container where the slideshow is running.

    And apparently the inititalisation of the slideshow doesn't work when the container is not visible. You should remove this in the script: window.onload = init; and place the call in the click event:

    onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';init();"

    I would recomment to create a function containing these instructions and call it in the click event.
    ×

    Success!

    Help @agli spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...