如何添加一个css类到Raphael对象 [英] how to add a css class to a Raphael object

查看:208
本文介绍了如何添加一个css类到Raphael对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个网页,使用很多Raphael对象,如线,矩形,圆。我使用不同的颜色为这些对象上的每个事件,如onmouseover一种颜色,onmouseout另一个等。所以,因为我有很多造型我想知道如果我可以指定一个CSS类这些对象。我尝试在IE上使用以下代码,但我看不到样式效果。

I'm trying to create a webpage which using a lot of Raphael objects like lines, rectangles, circle. I'm using different colors for each of the event on these objects like onmouseover one color, onmouseout another etc.. So since I have a lot of styling I was wondering if I can specify a css class to these objects. I tried using the following code on IE, but I could not see the styling effect

rectObj.attr('class','mediumBold');

mediumBold是定义的css类之一。

mediumBold is one the defined css class.

我很新鲜。任何指针都会有帮助。

I'm fairly new to this. Any pointer will be helpful.

谢谢。

推荐答案

我这样做:

var rph = Raphael("target",100,100);

var p = rph.rect(0, 0, 12, 12, 1);

p.node.setAttribute("class","track");

这篇关于如何添加一个css类到Raphael对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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