jQuery colorbox:如何更改colorbox的位置 [英] jQuery colorbox : How can I change the position of the colorbox

查看:260
本文介绍了jQuery colorbox:如何更改colorbox的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,颜色框在屏幕上垂直和水平居中显示.是否有办法将其更改为例如从垂直顶部垂直放置到水平居中位置更改为10%?

By default the colorbox appears centered both vertically and horizontally on the screen. Is there a way to change that, for example to 10% from top vertically and centered horizontally?

推荐答案

这将覆盖顶部位置,您可以对左等操作:

This will override the top position, and you can do the same with left etc:

#colorbox { top: 100px !important; }

自上而下10%会比较棘手,每次显示颜色框时,您都必须在onload回调中实现自己的定位逻辑,或者扩展颜色框的代码,但没有快速的方法.

10% from top would be trickier, you'd have to implement your own positioning logic in an onload callback everytime the colorbox is shown, or extend colorbox's code, but no quick way to do that.

更新

Colorbox现在有一个内置选项可以做到这一点:

Colorbox now has a built-in option to do this:

$("a").colorbox({ top: 100, left: "50%" })

更新2

如果您不绑定颜色盒,我强烈建议您使用 qTip2 .
更好的位置处理(jQuery UI样式),更清晰的HTML输出和更容易的IE< 8支持.

If you're not bound to colorbox, I highly recommend using qTip2.
Far better position handling (jQuery UI style), cleaner HTML output and easier IE<8 support.

这篇关于jQuery colorbox:如何更改colorbox的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆