jquery colorbox浏览图片中参数的配置

  

Settings

PropertyDefaultDescription
transition"elastic"The transition type. Can be set to "elastic", "fade", or "none".
speed350Sets the speed of the fade and elastic transitions, in milliseconds.
hreffalseThis 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"});
titlefalseThis can be used as an anchor title alternative for ColorBox.
relfalseThis 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.
scalePhotostrueIf true, and if maxWidth, maxHeight, innerWidth, innerHeight, width, or height have been defined, ColorBox will scale photos to fit within the those values.
scrollingtrueIf 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.
opacity0.85The overlay opacity level. Range: 0 to 1.
openfalseIf true, ColorBox will immediately open.
returnFocustrueIf true, focus will be returned when ColorBox exits to the element it was launched from.
fastIframetrueIf false, the loading graphic removal and onComplete event will be delayed until iframe's content has completely loaded.
preloadingtrueAllows for preloading of 'Next' and 'Previous' content in a group, after the current content has finished loading. Set to false to disable.
overlayClosetrueIf false, disables closing ColorBox by clicking on the background overlay.
escKeytrueIf false, will disable closing colorbox on 'esc' key press.
arrowKeytrueIf false, will disable the left and right arrow keys from navigating between the items in a group.
looptrueIf false, will disable the ability to loop back to the beginning of the group when on the last element.
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.
datafalseFor 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.
Content Type  
iframefalseIf true, specifies that content should be displayed in an iFrame.
inlinefalse

If true, content from the current document can be displayed by passing the href property a jQuery selector, or jQuery object.

// Using a selector:
$("#inline").colorbox({inline:true, href:"#myForm"});
 
// Using a jQuery object:
var $form = $("#myForm");
$("#inline").colorbox({inline:true, href:$form});
htmlfalse

For displaying a string of HTML or text.

$.colorbox({html:"<p>Hello</p>"});
photofalseIf 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.
Dimensions  
widthfalseSet a fixed total width. This includes borders and buttons. Example: "100%", "500px", or 500
heightfalseSet a fixed total height. This includes borders and buttons. Example: "100%", "500px", or 500
innerWidthfalseThis is an alternative to 'width' used to set a fixed inner width. This excludes borders and buttons. Example: "50%", "500px", or 500
innerHeightfalseThis is an alternative to 'height' used to set a fixed inner height. This excludes borders and buttons. Example: "50%", "500px", or 500
initialWidth300Set the initial width, prior to any content being loaded.
initialHeight100Set the initial height, prior to any content being loaded.
maxWidthfalseSet a maximum width for loaded content. Example: "100%", 500, "500px"
maxHeightfalseSet a maximum height for loaded content. Example: "100%", 500, "500px"
Slideshow  
slideshowfalseIf true, adds an automatic slideshow to a content group / gallery.
slideshowSpeed2500Sets the speed of the slideshow, in milliseconds.
slideshowAutotrueIf 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
Positioning  
fixedfalseIf 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.
topfalseAccepts 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.
bottomfalseAccepts 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.
leftfalseAccepts 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.
rightfalseAccepts 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.
Callbacks  
onOpenfalseCallback that fires right before ColorBox begins to open.
onLoadfalseCallback that fires right before attempting to load the target content.
onCompletefalseCallback that fires right after loaded content is displayed.
onCleanupfalseCallback that fires at the start of the close process.
onClosedfalseCallback 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' or 'innerWidth' 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_opentriggers when ColorBox is first opened, but after a few key variable assignments take place.
cbox_loadtriggers at the start of the phase where content type is determined and loaded.
cbox_completetriggers when the transition has completed and the newly loaded content has been revealed.
cbox_cleanuptriggers as the close method begins.
cbox_closedtriggers as the close method ends.

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值