google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Tạo một trình diễn ảnh trượt với jQuery Bài viết này hướng dẫn bạn chi tiết cách dùng thư viện jQuery để tạo một khung trưng bày ảnh đơn giản trên trang web, với sự hỗ trợ của các thư viện đồ họa người dùng. Vui lòng vào trang chi tiết để xem thêm.


Nhãn: trình diễn ảnh trượt, thư viện jQuery, khung trưng bày ảnh, đồ họa người dùng, UI

Miễn phí web hosting 1 năm đầu tại iPage



Nếu bạn vẫn còn đang tìm kiếm một nhà cung cấp hosting đáng tin cậy, tại sao không dành chút thời gian để thử với iPage, chỉ với không quá 40.000 VNĐ/tháng, nhưng bạn sẽ được khuyến mãi kèm với quà tặng trị giá trên 10.000.0000 VNĐ nếu thanh toán cho 24 tháng ~ 900.000 VNĐ?

Có trên 1 triệu khách hàng hiện tại của iPage đã & đang hài lòng với dịch vụ, tuyệt đối chắc chắn bạn cũng sẽ hài lòng giống họ! Quan trọng hơn, khi đăng ký sử dụng web hosting tại iPage thông qua sự giới thiệu của chúng tôi, bạn sẽ được hoàn trả lại toàn bộ số tiền bạn đã sử dụng để mua web hosting tại iPage. Wow, thật tuyệt vời! Bạn không phải tốn bất kì chi phí nào mà vẫn có thể sử dụng miễn phí web hosting chất lượng cao tại iPage trong 12 tháng đầu tiên. Chỉ cần nói chúng tôi biết tài khoản của bạn sau khi đăng ký.

Nếu muốn tìm hiểu thêm về ưu / nhược điểm của iPage, bạn hãy đọc đánh giá của ChọnHostViệt.com nhé!
Thử iPage miễn phí cho năm đầu tiên NGAY

Scrollable image slider  is one of the interesting features in the image gallery application. This allows us to display thumbnails in the form of slides that can be scrolled automatically or manually using the control buttons.

Figure below shows a scrollable image slider featuring four thumbnails per slide. To display thumbnails from another slide, simply by clicking the navigation buttons located on the right and left slide. Slides can also be scrolled automatically by using the  left and right arrow keyboard or using  the mouse wheel.

Scrollable image gallery

Scrollable image slider

In this tutorial, i'll use Scrollable component from jQuery Tools user interface (UI) library which is based on popular jQuery javascript framework. Current version of jQuery Tools at the time of this writing is version 1.1.2, which can be downloaded here. The library itself consists of six user interface components that can be easily combined:  Tabs, Tooltip, Overlay, Scrollable, Expose, and Flashembed.

How to Setup

  • Download Scrollable component from download page and save it as jquery.tools.min.js. You can download it with jQuery (v1.3.2)  as a single file (21.75 kb) or as a separated file (3.37 kb) if you already have jQuery.
  • Include the jquery.tools.min.js in the HEAD section of your HTML file
  • 1<script src="scripts/jquery.tools.min.js" type="text/javascript"></script>

    or

    1<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    2<script src="scripts/jquery.tools.min.js" type="text/javascript"></script>

Using Scrollable UI library

HTML Code

01<a class="prevPage left"></a>
02<div class="scrollable">
03    <div class="items">
04        <!-- 1-4 -->
09 
10        <!-- 5-8 -->
15 
16        <!-- 10-12 -->
21    </div>
22</div>
23 
24<a class="nextPage right"></a>

line 01:  element for left/prev  button.

line 02: root element (div) for the scrollable.

line 03: wrapper element.

line 04-20: scrollable images (will be displayed  four images per slide).

line 24: element for right/next button.

CSS Code

Scrollable

01.scrollable {
02    background: #ccc;
03    position: relative;
04    overflow: hidden;
05    width: 690px;
06    height:145px;
07    border:1px solid #ccc;
08    -moz-border-radius:4px;
09    -webkit-border-radius:4px;
10}
11 
12.scrollable .items {
13    width: 20000em;
14    position: absolute;
15    clear: both;
16}
17 
18.scrollable img {
19    opacity: 0.6;
20    float:left;
21    margin:15px 5px 15px 15px;
22    background-color:#fff;
23    cursor:pointer;
24    width:150px;
25    height:113px;
26    -moz-border-radius:4px;
27    -webkit-border-radius:4px;
28}
29 
30.scrollable .active {
31    opacity:1;
32    border:2px solid #000;
33    z-index:9999;
34    position:relative;
35}

line 01, style for  container element, the length and width depends on image size and how many images you want displayed per slide.

line 12, style for wrapper element.

line 18,  style for images in a slide.

line 30, style for selected image.

Navigation button (prev & next)

01.scrollable { float:left; }
02 
03a.left, a.right {
04    display: block;
05    width: 18px;
06    height: 18px;
07    float: left;
08    margin: 60px 10px;
09    cursor: pointer;
10}
11 
12a.right { background: url(scrollable/arrow/right.png) no-repeatclear:right; margin-right: 0px;}
13a.right:hover  { background-position:0px -18px; }
14a.right:active  { background-position:0px 0px; }
15 
16a.left  { background: url(scrollable/arrow/left.png) no-repeatmargin-left: 0px; }
17a.left:hover  { background-position:0px -18px; }
18a.left:active  { background-position:-0px 0px; }
19 
20a.disabled { visibility:hidden !important; }

line 01, allow next and  prev buttons placed on each side of the slide.

line 12,  set size and position of prev and next buttons.

line 16,  set background image for prev and next buttons.

Javascript Code

1<script>
2    $(function()  { $("div.scrollable").scrollable({size: 4}); });
3</script>

$("div.scrollable") is a jQuery selector for scrollabe container. On example above, we set four images for each slide using configuration parameter 'size'. Default value of 'size' parameter is 5. You can learn more about the API of the Scrollable component on this page.

View Live DemoDownload Example Source Code

iPhoneKer.com
Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language

Dall-E-OpenAI.com
Generate creative images automatically with AI

AIVideo-App.com
Render creative video automatically with AI

JavaScript theo ngày


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web