Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html>
    <head>
    	<title>Amazing Image Gallery</title>
        <meta charset="utf8">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    </head>
    <body>
        <h1>Amazing Image Gallery</h1>
            <!-- container for the main photo -->
            <div class="photoFrame">
                <a id="photoLink" target="_blank"><img id="largePhoto"></a>
            </div>
            <!-- container for the thumbnails -->
            <div id="thumbs">
                        <div class="left-arrow navigation" id="newPhoto" style="float: left;"></div>

                <img id="0">
                <img id="1">
                <img id="2">
                <img id="3"> 
                            <div class="right-arrow navigation" id="oldPhoto" style="float: right;"></div> 

            </div>
            <p> 
                © Carlos Kynäslahti 2015
            </p>
    </body>
</html>
            
          
!
            
              img {
    padding: 0px;
    line-height:0px;
    margin: 0px;
    float: left;
}

h1 {
    text-align: center; 
    font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
}

div.photoFrame {
    margin: 0 auto; 
    height: 600px; 
    width: 600px;
}

img#largePhoto {
    height: 600px;
    width: 600px;
}

div#thumbs {
    width: 50%; 
    margin: 0 auto;  
   height: 150px; 
    width: 900px;
}

div#thumbs img {
    width:150px;
    height:150px;
    overflow: hidden;
}

div#imageLoader {
    display: none;
}

p {
    font-family: 'Helvetica Neue', 'Lucida Grande'; 
    font-size: 11px;
}

img#iso{
    width:600px;
    height:600px;
}

#newPhoto:hover {
    border-color: transparent #545657 transparent transparent;
}

#oldPhoto:hover {
    border-color: transparent transparent transparent #545657;
}

.left-arrow {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 75px 150px 75px 0;
    border-color: transparent #c7c7c7 transparent transparent;
    display: inline;
}

.right-arrow {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 75px 0 75px 150px;
    border-color: transparent transparent transparent #c7c7c7;
    display: inline;

}

.cf:after {
    clear: both;
}

.tooltip {
    display: none;
    position: absolute;
    border: 1px solid #333;
    background-color: #161616;
    border-radius: 5px;
    padding: 10px;
    color: #fff;
    font-size: 12px Arial;
    width: 35%;
}
            
          
!
            
              $(document).ready(function(){
    // uses https://instagram.com/developer/endpoints/users/#get_users_media_recent to get 4 most recent pictures from Instagram. requires a registered client & permission from user
    var url = "https://api.instagram.com/v1/users/1551735546/media/recent/?access_token=1551735546.4bf074c.c50158944161461cb019d912fa816df9" 
    var instagramData, index, i;
    var  DEBUG = true;
    $.ajax({
		type: 'GET',
		url: url,
		contentType: "application/json",
		dataType: 'jsonp'
})
	.done(function(data){
        instagramData = data.data; 
        // preloads all 20 standard resolution photos
        var imgArray = [];
        for (i = 0; i < instagramData.length; i++){
            var image = new Image();
            //console.log(instagramData[i]);
            image.src = instagramData[i].images.standard_resolution.url;
            imgArray.push( image );
        }
        // loads initial main photo, URL to Instagram and Instagram caption text
        $("#largePhoto").attr("src", instagramData[0].images.standard_resolution.url ); 
        $("#photoLink").attr("href", instagramData[0].link );
        $("#photoLink").attr("title", instagramData[0].caption.text );
        // tooltip by Alessio Atzeni (http://www.alessioatzeni.com/blog/simple-tooltip-with-jquery-only-text/) to display Instagram caption text when hovering
        $("#photoLink").hover(function(){
            var title = $(this).attr('title');
            $(this).data('tipText', title).removeAttr('title');
            $('<p class="tooltip"></p>')
            .text(title)
            .appendTo('body')
            .fadeIn('slow');
        // removes tooltip when mouse leaves photo
        }, function () {
            $('this').attr('title', $(this).data('tipText'));
            $('.tooltip').remove();
            $("#photoLink").attr("title", $(this).data('tipText') );
        // captures mouse position on screen 
        }).mousemove(function(e){
            var mousex = e.pageX + 10; 
            var mousey = e.pageY + 10;
            $('.tooltip')
            .css({ top: mousey, left: mousex })
        });

        index = 0; 
        // loops to generate four thumbnail photos
        for (i = 0; i <= 3; i++){ 
        $("#"+i).attr("src", instagramData[i].images.thumbnail.url )
        }
        // clicks on navigation buttons reduce or increase index number to receive a new array
        $(".navigation").click(function(){
           if ($(this).attr("id") == "oldPhoto" && index < 16) {
            ++index; 
           } else if ($(this).attr("id") == "newPhoto" && index >= 1) {
            --index;
           }
            for (i = 0; i <= 3; i++){ 
                $("#"+i).attr("src", instagramData[i+index].images.thumbnail.url )
            }
        })
        
        // thumbnail mouse hover
        $("#thumbs img").hover(function (){   
        // hover over thumbnails launches effects              
            $("#largePhoto").fadeOut(300);                  
            $("#largePhoto").fadeIn(300);
            // loads the main photo by combining id value with var index and fetching the sum from the array
            var elemId = this;                           
            setTimeout(function(){
                if (DEBUG){
                    console.log("index number:" + index)
                    console.log("This is id: " + $(elemId).attr("id"))
                }
                $("#largePhoto").attr("src", instagramData[parseInt($(elemId).attr("id"))+ index ].images.standard_resolution.url);
                $("#photoLink").attr("href", instagramData[parseInt($(elemId).attr("id"))+ index ].link);
                $("#photoLink").attr("title", instagramData[parseInt($(elemId).attr("id"))+ index ].caption.text);
                }, 300);
            },  function(){
            // when the cursors leaves a thumbnail, stops the animation and shows the main photo
            $("#largePhoto").stop( true, true );
            $("#largePhoto").show();                    
            });
    }); 
});











            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console