View Demos
Download
Released under the MIT License. Source on Github (changelog).
Compatible with: jQuery 1.3.2+ in Firefox, Safari, Chrome, Opera, Internet Explorer 7+
Bower Package: jquery-colorbox
<iframe style="box-sizing: border-box; margin: 0px; padding: 0px; border-width: 0px;" src="http://ghbtns.com/github-btn.html?user=jackmoore&repo=colorbox&type=watch&count=true" frameborder="0" scrolling="0" width="97" height="20"></iframe> <iframe style="box-sizing: border-box; margin: 0px; padding: 0px; border-width: 0px;" src="http://ghbtns.com/github-btn.html?user=jackmoore&repo=colorbox&type=fork&count=true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
- Supports photos, grouping, slideshow, ajax, inline, and iframed content.
- Lightweight: 10KB of JavaScript (less than 5KBs gzipped).
- Appearance is controlled through CSS so it can be restyled.
- Can be extended with callbacks & event-hooks without altering the source files.
- Completely unobtrusive, options are set in the JS and require no changes to existing HTML.
- Preloads upcoming images in a photo group.
- Currently used on more than 1.9 million websites.
Instructions & Help
The FAQ has instructions on asking for help, solutions to common problems, and how-to examples. First-time jQuery users can check out the Colorbox Beginner's Guide. Intermediate users can probably glean everything needed by view-source'ing the demo pages.
Usage
Colorbox accepts settings from an object of key/value pairs, and can be assigned to any HTML element.
// Format:
$(selector).colorbox({key:value, key:value, key:value});
// Examples:
// Image links displayed as a group
$('a.gallery').colorbox({rel:'gal'});
// Ajax
$('a#login').colorbox();
// Called directly, without assignment to an element:
$.colorbox({href:"thankyou.html"});
// Called directly with HTML
$.colorbox({html:"<h1>Welcome</h1>"});
// Colorbox can accept a function in place of a static value:
$("a.gallery").colorbox({rel: 'gal', title: function(){
var url = $(this).attr('href');
return '<a href="' + url + '" target="_blank">Open In New Window</a>';
}});
Settings
transition | "elastic" | 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 | This can be used as an alternative anchor URL or to associate a URL for non-anchor elements such as images or form buttons. $("h1").colorbox({href:"welcome.html"});
|
title | false | This can be used as an anchor title alternative for Colorbox. |
rel | false | 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.$("a.gallery").colorbox({rel:"group1"}); Note: The value can also be set to 'nofollow' to disable grouping. |
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. |
opacity | 0.85 | The overlay opacity level. Range: 0 to 1. |
open | false | If true, Colorbox will immediately open. |
returnFocus | true | If true, focus will be returned when Colorbox exits to the element it was launched from. |
trapFocus | true | If true, keyboard focus will be limited to Colorbox's navigation and content. |
fastIframe | true | If false, the loading graphic removal and onComplete event will be delayed until iframe's content has completely loaded. |
preloading | true | Allows for preloading of 'Next' and 'Previous' content in a group, after the current content has finished loading. Set to false to disable. |
overlayClose | true | If false, disables closing Colorbox by clicking on the background overlay. |
escKey | true | If false, will disable closing colorbox on 'esc' key press. |
arrowKey | true | If false, will disable the left and right arrow keys from navigating between the items in a group. |
loop | true | If false, will disable the ability to loop back to the beginning of the group when on the last element. |
data | false | For submitting GET or POST values through an ajax request. The data property will act exactly like jQuery's .load() data argument, as Colorbox uses .load() for ajax handling. |
className | false | Adds a given class to colorbox and the overlay. |
fadeOut | 300 | Sets the fadeOut speed, in milliseconds, when closing Colorbox. |
closeButton | true | Set to false to remove the close button. |
current | "image {current} of {total}" | Text or HTML for the group counter while viewing a group. {current} and {total} are detected and replaced with actual numbers while Colorbox runs. |
previous | "previous" | Text or HTML for the previous button while viewing a group. |
next | "next" | Text or HTML for the next button while viewing a group. |
close | "close" | Text or HTML for the close button. The 'esc' key will also close Colorbox. |
xhrError | "This content failed to load." | Error message given when ajax content for a given URL cannot be loaded. |
imgError | "This image failed to load." | Error message given when a link to an image fails to load. |
iframe | false | If true, specifies that content should be displayed in an iFrame. |
inline | false |
If true, content from the current document can be displayed by passing the href property a jQuery selector, or jQuery object.
|
html | false | For displaying a string of HTML or text: $.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') |
ajax | This property isn't actually used as Colorbox assumes all hrefs should be treated as either ajax or photos, unless one of the other content types were specified. | |
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" |
slideshow | false | If true, adds an automatic slideshow to a content group / gallery. |
slideshowSpeed | 2500 | Sets the speed of the slideshow, in milliseconds. |
slideshowAuto | 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 |
fixed | false | If true, Colorbox will be displayed in a fixed position within the visitor's viewport. This is unlike the default absolute positioning relative to the document. |
top | false | Accepts a pixel or percent value (50, "50px", "10%"). Controls Colorbox's vertical positioning instead of using the default position of being centered in the viewport. |
bottom | false | Accepts a pixel or percent value (50, "50px", "10%"). Controls Colorbox's vertical positioning instead of using the default position of being centered in the viewport. |
left | false | Accepts a pixel or percent value (50, "50px", "10%"). Controls Colorbox's horizontal positioning instead of using the default position of being centered in the viewport. |
right | false | Accepts a pixel or percent value (50, "50px", "10%"). Controls Colorbox's horizontal positioning instead of using the default position of being centered in the viewport. |
reposition | true | Repositions Colorbox if the window's resize event is fired. |
retinaImage | false | If true, Colorbox will scale down the current photo to match the screen's pixel ratio |
retinaUrl | false | If true and the device has a high resolution display, Colorbox will replace the current photo's file extention with the retinaSuffix+extension |
retinaSuffix | "@2x.$1" | If retinaUrl is true and the device has a high resolution display, the href value will have it's extention extended with this suffix. For example, the default value would change `my-photo.jpg` to `my-photo@2x.jpg` |
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. |
Public Methods
$.colorbox() | This method allows you to call Colorbox without having to assign it to an element. $.colorbox({href:"login.php"});
|
$.colorbox.next() $.colorbox.prev() |
These methods moves to the next and previous items in a group and are the same as pressing the 'next' or 'previous' buttons. |
$.colorbox.close() | This method initiates the close sequence, which does not immediately complete. The lightbox will be completely closed only when the cbox_closed event / onClosed callback is fired. |
$.colorbox.element() | This method is used to fetch the current HTML element that Colorbox is associated with. Returns a jQuery object containing the element. var $element = $.colorbox.element();
|
$.colorbox.resize() | This allows Colorbox to be resized based on it's own auto-calculations, or to a specific size. This must be called manually after Colorbox's content has loaded. The optional parameters object can accept width orinnerWidth and height or innerHeight . Without specifying a width or height, Colorbox will attempt to recalculate the height of it's current content. |
$.colorbox.remove() | Removes all traces of Colorbox from the document. Not the same as $.colorbox.close(), which tucks colorbox away for future use. |
Event Hooks
These event hooks fire at the same time as their corresponding callbacks (ie. cbox_complete & onComplete), but can be used to make a universal change to Colorbox, while callbacks are only applied to selected elements.
// Example of using an event listener and public method to build a primitive slideshow:
$(document).bind('cbox_complete', function(){
setTimeout($.colorbox.next, 1500);
});
cbox_open | triggers when Colorbox is first opened, but after a few key variable assignments take place. |
cbox_load | triggers at the start of the phase where content type is determined and loaded. |
cbox_complete | triggers when the transition has completed and the newly loaded content has been revealed. |
cbox_cleanup | triggers as the close method begins. |
cbox_closed | triggers as the close method ends. |
http://www.cnblogs.com/keepfool/archive/2012/05/26/2519365.html
相关推荐
Jupyter-Notebook
考研公共课历年真题集-最新发布.zip
2006-2023年上市公司资产误定价Misp数据集(4.9万样本,含原始数据、代码及结果,最新).zip
Jupyter-Notebook
Jupyter-Notebook
100个Origin软件高效使用技巧大全-最新更新.zip
Jupyter-Notebook
煤矿感知数据联网接入规范 第2部分:重要设备
1、资源内容地址:https://blog.csdn.net/abc6838/article/details/143777985 2、数据特点:今年全新,手工精心整理,放心引用,数据来自权威,且标注《数据来源》,相对于其他人的控制变量数据准确很多,适合写论文做实证用 ,不会出现数据造假问题 3、适用对象:大学生,本科生,研究生小白可用,容易上手!!! 4、课程引用: 经济学,地理学,城市规划与城市研究,公共政策与管理,社会学,商业与管理
KSSJ_CJ15-2023
全国电子地图行政区划道路水系数据-最新shp.zip
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
全国乡镇级行政区划矢量数据2.0版-最新.zip
Jupyter-Notebook
Typora(version 1.2.3)导出 pdf 自定义水印的 frame.js 文件,详情可以查看:
【作品名称】:基于Java 实现的电脑鼠走迷宫的软件程序 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】: 迷宫地图生成算法的设计和实现 自动生成迷宫:根据迷宫生成算法自动生成一定复杂度的迷宫地图。 手动生成迷宫:根据文件中存储的固定数据生成迷宫地图。 单路径寻找算法的设计与实现:找出迷宫中一条单一的通路。 迷宫遍历算法的设计与实现:遍历迷宫中所有的可行路径。 最短路径计算算法的设计与实现:根据遍历结果,找出迷宫中所有通路中的最短通路。 (3)第二部分:界面展示部分 生成迷宫地图界面的设计与实现:根据生成的迷宫地图,用可视化的界面展现出来。 界面布局的设计与实现:根据迷宫程序的总体需求,设计和实现合理的界面布局。 相关迷宫生成过程和寻路算法在界面上的展现:将迷宫程序中的相关功能,跟界面合理结合,并采用一定的方法展 【资源声明】:本资源作为“参考资料”而不是“定制需求”,代码只能作为参考,不能完全复制照搬。需要有一定的基础看懂代码,自行调试代码并解决报错,能自行添加功能修改代码。
基于Selenium前端自动化测试工具,对youtube和tiktok数据进行爬虫,可设置自己要爬取的内容和主题,快速便捷。
Jupyter-Notebook
gkt
Jupyter-Notebook