Loading...

Creating a simple Image Gallery With jQuery

View: 781    Dowload: 0   Comment: 0   Post by: hanhga   Category: References   Fields: Other

Today I would like to share with you a simple imaging applications that are commonly used on websites, especially for web slideshows, studio ... just a few lines of code for creating jQuery and CSS fade.

jQuery Code

1
2
3
4
5
6
jQuery('.photo-thumbnails .thumbnail').click(function() {
    jQuery('.photo-thumbnails .thumbnail').removeClass('current');
    jQuery(this).addClass('current');
    var path = jQuery(this).find('img').attr('src');
    jQuery('#big-photo img').attr('src', path);
});

I would like to explain a few lines of code on jQuery as follows:

1
jQuery('.photo-thumbnails .thumbnail').removeClass('current');

This code is used to set the class "current" in the newly click thumbnails.

1
var path = jQuery(this).find('img').attr('src');

This code is used to get the attribute "src" of the image has been clicked.

1
jQuery('#big-photo img').attr('src', path);

This code is used to set the attribute "src" of great photos.

CSS Code

To be able to create fade effects, then we need to have the following CSS snippet:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
.gallery-photos {
    padding: 20px;
}
.gallery-photos .big-photo {
    display: block;
    background-color: #ffffff;
    padding: 3px;
    border: 1px solid #e7e7e7;
    margin-right: 210px;
}
.gallery-photos .big-photo img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
.gallery-photos .photo-thumbnails {
    float: right;
    width: 210px;
}
.gallery-photos .photo-thumbnails .thumbnail {
    float: left;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    width: 30%;
    height: 63px;
    cursor: pointer;
    padding: 3px;
    border: 1px solid #e7e7e7;
    margin-left: 3.33333%;
    margin-bottom: 6px;
    opacity: 0.4;
}
.gallery-photos .photo-thumbnails .thumbnail.current {
    opacity: 1;
    background-color: #ffffff;
}
.gallery-photos .photo-thumbnails .thumbnail .thumbnail-inner {
    height: 100%;
    overflow: hidden;
}
.gallery-photos .photo-thumbnails .thumbnail img {
    display: block;
    width: auto;
    max-height: 100%;
    margin: 0 auto;
}

HTML Code

Finally, we need a standard frame html as follows:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<div class="gallery-photos clearfix">
  <div class="photo-thumbnails">
    <div class="thumbnail current">
      <div class="thumbnail-inner"> <img src="images/1.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/2.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/3.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/4.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/5.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/6.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/7.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/8.jpg" alt="" /> </div>
    </div>
    <div class="thumbnail">
      <div class="thumbnail-inner"> <img src="images/9.jpg" alt="" /> </div>
    </div>
  </div>
  <div id="big-photo" class="big-photo"> <img src="images/1.jpg" alt="" /> </div>
</div>

Very simple and straightforward is not it, if you have any questions something, leave a message in the form of comments, I will try to explain as soon as possible.

Good luck!

Creating a simple Image Gallery With jQuery

Today I would like to share with you a simple imaging applications that are commonly used on websites, especially for web slideshows, studio ... just a few lines of code for creating jQuery and CSS fade.

Posted on 06-08-2015 

Comment:

To comment you must be logged in members.

Files with category

  • Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    View: 3379    Download: 0   Comment: 0

    Category: References     Fields: Other

    Windows 10 pre-installed Mail application for managing personal email on the device. The latest version of this application but improved a lot and support other email accounts such as Gmail or Yahoo Mail but users almost no "salty" really with this...

  • Step by step instructions to create social networking buttons with CSS3

    Step by step instructions to create social networking buttons with CSS3

    View: 2354    Download: 0   Comment: 0

    Category: References     Fields: Other

    CSS3 help web designers have the ability to create buttons (buttons) very nice, today I will share with you two tips decoration for button in your web becomes radiant beauty that no need to use photoshop.

  • You should understand the CSS Box Shadow

    You should understand the CSS Box Shadow

    View: 2435    Download: 0   Comment: 0

    Category: References     Fields: Other

    Effects his shadow was introduced in the previous article, however, in this article, I will guide more specific about shadow attributes, you try it with anything. First we try to learn css following paragraph:

  • How to do button movement with beautiful CSS3

    How to do button movement with beautiful CSS3

    View: 2120    Download: 0   Comment: 0

    Category: References     Fields: Other

    Previously to create motion effects button, you must draw the button in photoshop, then switched to flash to make it possible to move. But now you need not spend too much time doing it, all because of the emergence of CSS3.

  • Create a dropdown menu with CSS3 effects with beautiful transtions

    Create a dropdown menu with CSS3 effects with beautiful transtions

    View: 2327    Download: 0   Comment: 0

    Category: References     Fields: Other

    More of the dropdown menu you want to introduce to you, this will have the effect menu transitions (converted background of menu background from pale to dark). This menu works well on browsers like FF, Chrome, Safary, but unfortunately did not work...

  • How to hack css for all browsers you should know

    How to hack css for all browsers you should know

    View: 1920    Download: 0   Comment: 0

    Category: References     Fields: Other

    In the process of web design, which makes it the most headaches is how to design web pages that you can run on the browser. Especially when clients use the old as IE6 browser such. However, with this article, you will easily edit interface runs well...

  • Create Accordion with extremely beautiful CSS3

    Create Accordion with extremely beautiful CSS3

    View: 2430    Download: 0   Comment: 0

    Category: References     Fields: Other

    Accordion is a technique that helps you shortened the content that you want displayed on the website. It is often used for the display of submenus. In addition you can also use it for content, images. Before applying this procedure, you have to use...

  • Create the effect Hovercho images with Webkit and CSS3 is great

    Create the effect Hovercho images with Webkit and CSS3 is great

    View: 2052    Download: 0   Comment: 0

    Category: References     Fields: Other

    WebKit is one open source application framework provides the necessary components built one for your web browser. Along with CSS3, cả have contributed to very nice effect những previously only using JavaScript or JQuery thực beige.​

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd