ColorBox 演示和说明/API:
轻量级,可定制的 lightbox 插件,适用于 jQuery 1.3和1.4
http://colorpowered.com/colorbox/
我们要使用 ColorBox
- 支持 照片,照片组,幻灯片,ajax,内联 和 iframe 框架。Supports photos, photo groups, slideshow, ajax, inline, and iframed content.
- 轻量级,不超过9kb 的javascript 代码。Lightweight: less than 9KB of JavaScript.
- 通过CSS 控制外观,使用用户可以很容易重新定制外观。Appearance is controlled through CSS so users can restyle the box.
- 不需要更改 ColorBox 的 javascript 文件就可以重新设定其行为。Behavior settings can be over-written without altering the ColorBox javascript file.
- 可以依靠 callback & event-hooks 进行拓展,不需要修改源代码。Can be extended with callbacks & event-hooks without altering the source files.
- 非常友好,不需要修改现有的 HTML,所有的选项都通过 JS 设置。Completely unobtrusive, options are set in the JS and require no changes to existing HTML.
- 预载背景图片和图片组里的其他图片。Preloads background images and can preload upcoming images in a photo group.
- Written in jQuery plugin format and can be chained with other jQuery commands.
- Generates W3C valid XHTML and adds no JS global variables & passes JSLint.
- Released under the MIT License.
兼容: Firefox 2 & 3, Safari 3 & 4, Opera 9, Chrome, Internet Explorer 6, 7, 8.
使用说明
colorbox 方法有一个 key/value 对象和一个 callback 选项。The colorbox method takes a key/value object and an optional callback.
格式: $('selector').colorbox({key:value, key:value, key:value}, callback);
示例: $('a#login').colorbox({transition:'fade', speed:500});
示例: $('a.gallery').colorbox();
示例: $('button').colorbox({href:"thankyou.html"});
直接打开,不需要把方法赋给元素。And it can be called directly, without assignment to an element
Example: $.fn.colorbox({href:"thankyou.html"});
ColorBox 可以接受自定于函数代替静态变量。ColorBox can accept a function in place of a static value:
$("a[rel='example']").colorbox({title: function(){
var url = $(this).attr('href');
return '<a href="'+url+'" target="_blank">Open In New Window</a>';
}});
演示页面的大量源码示例。Follow the source code on the demonstration pages for plenty of examples.
transition | "elastic" | 过渡效果,可以设置为elastic,fade 或 none。The transition type. Can be set to "elastic", "fade", or "none". |
speed | 350 | 过渡效果的速度,单位毫秒。Sets the speed of the fade and elastic transitions, in milliseconds. |
href | false | 这儿可以说锚点链接,或者像 image、button 这样非锚点元素上的链接。This can be used as an alternative anchor URL or to associate a URL for non-anchor elements such as images or form buttons. Example: $('h1').colorbox({href:"welcome.html"}) |
title | false | 锚点的title 可以用作 ColorBox 的title。This can be used as an anchor title alternative for ColorBox. |
rel | false | 在 ColorBox里这个可以看作一个锚点。用户可以靠它把任何元素组合中一起成一个相册。反之就不能组合中一起。This can be used as an anchor rel alternative for ColorBox. This allows the user to group any combination of elements together for a gallery, or to override an existing rel so elements are not grouped together. Example: $('#example a').colorbox({rel:'group1'}) 注:这里也可以设置为‘nofollow’来关掉编组。 The value can also be set to 'nofollow' to disable grouping. |
width | false | 固定宽度,其包含 边框和按钮。Set a fixed total width. This includes borders and buttons. Example: "100%", "500px", or 500 |
height | false | 固定高度,其包含 边框和按钮。Set a fixed total height. This includes borders and buttons. Example: "100%", "500px", or 500 |
innerWidth | false | This is an alternative to 'width' used to set a fixed inner width. This excludes borders and buttons. Example: "50%", "500px", or 500 |
innerHeight | false | This is an alternative to 'height' used to set a fixed inner height. This excludes borders and buttons. Example: "50%", "500px", or 500 |
initialWidth | 300 | Set the initial width, prior to any content being loaded. |
initialHeight | 100 | Set the initial height, prior to any content being loaded. |
maxWidth | false | Set a maximum width for loaded content. Example: "100%", 500, "500px" |
maxHeight | false | Set a maximum height for loaded content. Example: "100%", 500, "500px" |
scalePhotos | true | If 'true' and if maxWidth, maxHeight, innerWidth, innerHeight, width, or height have been defined, ColorBox will scale photos to fit within the those values. |
scrolling | true | If 'false' ColorBox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method (see below) for a smoother transition if you are appending content to an already open instance of ColorBox. |
iframe | false | If 'true' specifies that content should be displayed in an iFrame. |
inline | false | If 'true' a jQuery selector can be used to display content from the current page. Example: $("#inline").colorbox({inline:true, href:"#myForm"}); |
html | false | 可以使用 HTML 字符串代替牵涉的内容。This allows an HTML string to be used directly instead of pulling content from another source (ajax, inline, or iframe). Example: $.fn.colorbox({html:'<p>Hello</p>'}); |
photo | false | If true, this setting forces ColorBox to display a link as a photo. Use this when automatic photo detection fails (such as using a url like 'photo.php' instead of 'photo.jpg', 'photo.jpg#1', or 'photo.jpg?pic=1') |
opacity | 0.85 | 覆盖层的透明级别(0-1).The overlay opacity level. Range: 0 to 1. |
open | false | 如果是 true,lightbox 会自动打开而不需要任何动作。If true, the lightbox will automatically open with no input from the visitor. |
preloading | true | Allows for preloading of 'Next' and 'Previous' content in a shared relation group (same values for the 'rel' attribute), after the current content has finished loading. Set to 'false' to disable. |
overlayClose | true | 如果是true,点击背景覆盖层将关闭 ColorBox。If true, enables closing ColorBox by clicking on the background overlay. |
slideshow | false | 如果是true,内容组或者相册将自动添加到幻灯片。If true, adds an automatic slideshow to a content group / gallery. |
slideshowSpeed | 2500 | 设置幻灯片的速度,单位毫秒。Sets the speed of the slideshow, in milliseconds. |
slideshowAuto | true | 如果是 true,幻灯片会自动开始播放。If true, the slideshow will automatically start to play. |
slideshowStart | "start slideshow" | 幻灯片开始按钮。Text for the slideshow start button. |
slideshowStop | "stop slideshow" | 幻灯片停止按钮。Text for the slideshow stop button |
current | "{current} of {total}" | Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while ColorBox runs. |
previous | "previous" | Text for the previous button in a shared relation group (same values for 'rel' attribute). |
next | "next" | Text for the next button in a shared relation group (same values for 'rel' attribute). |
close | "close" | Text for the close button. The 'Esc' key will also close ColorBox. |
onOpen | false | Callback that fires right before ColorBox begins to open. |
onLoad | false | Callback that fires right before attempting to load the target content. |
onComplete | false | Callback that fires right after loaded content is displayed. |
onCleanup | false | Callback that fires at the start of the close process. |
onClosed | false | Callback that fires once ColorBox is closed. |
帮助:
如果你有什么问题或疑惑,请访问这里:
http://groups.google.com/group/colorbox/topics
文章出处:http://www.yaoin.net/css/jquery/colorbox/
相关推荐
这个教程将帮助你理解和掌握Colorbox的使用方法,包括其API接口和中文指南。 首先,我们来了解Colorbox的基本用法。在HTML中,你可以通过添加特定的类或者数据属性来标记需要弹出显示的内容。例如,对于图片,可以...
在网页设计中,Colorbox以其简洁的API和强大的功能,深受开发者喜爱。下面,我们将深入探讨jQuery Colorbox的核心概念、使用方法及常见应用场景。 一、jQuery Colorbox基础 1. 安装与引入 要使用jQuery Colorbox,...
在"ColorBox样式例子"中,我们将探讨如何在实际项目中应用和定制ColorBox。 首先,ColorBox的核心功能是创建一个可自定义的弹出窗口,用于显示单张或一组图片。它支持预加载图像,提供平滑的过渡效果,并且可以轻松...
7. **API控制**:提供API接口,可以方便地在代码中控制Colorbox的打开、关闭和更新内容。 安装和使用jQuery Colorbox非常简单。首先,你需要在页面中引入jQuery库和Colorbox的CSS及JS文件。然后,通过jQuery选择器...
其简洁的API和丰富的功能使其成为许多开发者首选的弹窗解决方案。 总结,jQuery ColorBox是一个强大且灵活的插件,为网页开发提供了优雅的弹出窗口解决方案。通过理解和应用这些知识点,你可以充分利用它来提升用户...
在`colorbox-master`压缩包中,通常会包含示例代码、样式文件、JavaScript文件以及演示所需的资源。通过查看这些文件,你可以更深入地了解`jQuery ColorBox`的使用方法和功能。 综上所述,`jQuery ColorBox`以其...
ColorBox library Features Dynamic color preview; Change the color through Alpha, Red, Green, and Blue sliders; Clearable recent colors; Material palettes (>200 colors!); ColorBox preference; ...
演示实例:http://colorpowered.com/colorbox/core/example1/index.html 3.FancyBox 官方网站:http://fancybox.net 下载地址:http://fancybox.googlecode.com/files/jquery.fancybox-1.2.5.zip 演示实例:...
在网页设计中,弹出框常用于显示图片、视频、内嵌页面等,而Colorbox以其简洁的界面和高度可定制性受到开发者们的青睐。本篇文章将深入探讨Colorbox的核心功能、使用方法及其实现的原理。 ### 1. 功能概述 - **...
**jQuery colorbox插件详解** `jQuery colorbox`是一款基于jQuery库的轻量级、高度可定制的弹出框插件,通常...其简单易用的API和丰富的配置选项,使得开发者可以根据实际需求轻松定制出符合自己风格的弹出框效果。
除了通过HTML标记触发,还可以通过JavaScript API手动打开Colorbox,例如`$.fn.colorbox(options)`,灵活控制何时打开和关闭窗口。 9. **与其他库的兼容性** Colorbox设计得足够灵活,可以与Bootstrap、jQuery UI...
6. **API控制**:开发者可以通过JavaScript API来控制colorBox的打开、关闭、切换等行为,灵活地集成到项目中。 在实际应用中,我们首先需要在项目中引入jQuery库和colorBox的CSS及JS文件。然后,通过简单的jQuery...
总结来说,ColorBox是一款强大的jQuery相册查看控件,它凭借其优秀的性能、丰富的功能和易于使用的API,成为了网页开发中不可或缺的工具之一。无论是在个人博客、电子商务网站还是企业官网,ColorBox都能为图片展示...
《jQuery Colorbox弹出层插件:实现图片弹出显示的代码详解》 在Web开发中,为了提供更好的用户体验,我们常常需要...在实际应用中,不断探索和实践,你会发现Colorbox的强大之处,为你的网站增添更多互动性和吸引力。
此外,还可以通过查看演示页面的源代码获取更多关于如何高效使用 Colorbox 的信息。 #### 常见问题与帮助 针对初次使用 jQuery 的用户,Colorbox 提供了一份新手指南,可以帮助快速上手。此外,FAQ 部分还提供了...
在网页设计中,巧妙运用Colorbox可以提升网站的交互性和用户体验,下面我们将深入探讨Colorbox的核心特性和使用方法。 1. **基础概念**: Colorbox是一款JavaScript库,通过jQuery框架进行操作,实现了在网页上以...
- **API控制**:可以使用Colorbox的API手动打开、关闭或切换弹出内容。 5. **优化与兼容性**: - **响应式设计**:Colorbox支持响应式布局,适应不同设备和屏幕尺寸。 - **浏览器兼容**:虽然主要依赖于现代...
Colorbox通过其丰富的功能和对各种浏览器的良好兼容性,为网站增添了一种吸引用户注意力的方式。 ### 1. jQuery Colorbox的基本用法 使用jQuery Colorbox,通常需要以下几步操作: 1. **引入依赖**:首先确保在...
对于每一段关键代码,都应有简短明了的说明,解释其功能和用法。 四、具体实践 在提供的“分组用户信息管理 - 代码”文件中,可以看到我们如何在用户列表中运用Colorbox。当用户点击某条记录时,通过Colorbox弹出...