随机边框颜色
我正在为 tumblr 网站设置主题,发布的每个图像都包含在“.photobox”类中。是否有一段 javascript 或 jQuery 我可以用来将 CSS 中“.photobox”的“border-color”属性更改为随机颜色 - 最好从预定义颜色列表中选择?我在这里找到了一两个脚本,但它们似乎不起作用。
I'm in the middle of theming a tumblr site, and each image posted is contained within a ".photobox" class. Is there a piece of javascript or jQuery i can use to change the "border-color" attribute of ".photobox" in the CSS to a random color - preferably chosen from a list of pre-defined colours? I've found one or two scripts on here but they don't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
自动更改间隔
一次性随机颜色
单个容器内的许多图像
jQuery 解决方案
Auto-changing Intervals
One-time Random Color
Many Images within Single Container
jQuery Solution
JavaScript 无法更改 CSS 规则集。您必须声明一个新的 CSS 规则集并将其分配给 DIV 或每个图像。喜欢
Javascript can not change CSS ruleset. You will have to declare a new CSS ruleset and assign it to DIV or to each image. Like
就这样:http://jsbin.com/afadu
There you go: http://jsbin.com/afadu
我不确定,这可能是可能的 http://plugins.jquery.com/node/ 11985 下载 zip 并查看文件的源代码。它用于表格,颜色是随机的,但我认为我们可以给出固定的颜色代码
I'm not sure, it may be possible by this http://plugins.jquery.com/node/11985 download zip and see source code of file. It;s for table and colors are random but i think we can give fixed color code
根据您的评论,您想要这样的内容:
getElementByClassName
是从 此处。Based on your comment you want something like this:
The
getElementByClassName
was copied from here.