Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 设置Raphael从外部样式表创建的VML元素的样式_Css_Svg_Internet Explorer 8_Raphael_Vml - Fatal编程技术网

Css 设置Raphael从外部样式表创建的VML元素的样式

Css 设置Raphael从外部样式表创建的VML元素的样式,css,svg,internet-explorer-8,raphael,vml,Css,Svg,Internet Explorer 8,Raphael,Vml,我正在用Raphael.js构建图表,图表上附带了各种样式,包括不同的悬停样式。以下内容可跨浏览器使用: var bar = paper.rect(x, y, width, height) .attr({"stroke-width": 0, fill: #baeadd; "fill-opacity": 0.3}) 为了将外观与功能完全分离,我尝试使用CSS来定位Raphael元素,并从中添加所有样式 我使用了概述的技术,能够使用唯一的ID-s在所有浏览器中定位我的

我正在用Raphael.js构建图表,图表上附带了各种样式,包括不同的悬停样式。以下内容可跨浏览器使用:

var bar = paper.rect(x, y, width, height)
               .attr({"stroke-width": 0, fill: #baeadd; "fill-opacity": 0.3})
为了将外观与功能完全分离,我尝试使用CSS来定位Raphael元素,并从中添加所有样式

我使用了概述的技术,能够使用唯一的ID-s在所有浏览器中定位我的形状:

bar.node.id = "bar-" + id;
-

以上内容在IE8上不起作用,Raphael在IE8中注入了vml形状元素。我能够指定标准CSS属性,例如
背景色
,shape元素将获得良好的样式,但我想知道如何应用属性,例如
填充不透明度
笔划宽度
,等等


解释
行为的作用:url(#default#VML)
。我可以看到Raphael已经为它创建的所有形状元素添加了一个
.rvml
类,并应用了这个行为属性,但是,当我停止通过JS应用属性并开始在CSS中指定它们时,它似乎不会立即生效。

没有办法做到这一点,因为IE8要求在VML元素上设置属性

基于to,您应该能够使用文件读取样式表中应用的文件,并将其映射到相应的样式表中

首先创建行为文件,例如:vmlcss.htc

<PUBLIC:COMPONENT>
<SCRIPT LANGUAGE="JScript">

var currentStyle = element.currentStyle;
if (currentStyle)
{
    // Apply stroke style
    element.stroked = currentStyle["stroke"] && currentStyle["stroke"] != "none";
    if (element.stroked)
    {
        element.strokecolor = currentStyle["stroke"] || "none";
        element.strokeweight = currentStyle["stroke-width"] || "1px";
    }

    // Apply fill style
    element.filled = currentStyle["fill"] != "none";
    if (element.filled)
    {
        element.fillcolor = currentStyle["fill"] || "Black";
    }
}
</SCRIPT>
</PUBLIC:COMPONENT>

var currentStyle=element.currentStyle;
如果(当前样式)
{
//应用笔划样式
element.stroked=currentStyle[“stroke”]&¤tStyle[“stroke”]!=“无”;
if(元素冲程)
{
element.strokecolor=currentStyle[“stroke”]| |“none”;
element.strokeweight=currentStyle[“笔划宽度”]| |“1px”;
}
//应用填充样式
element.filled=currentStyle[“fill”]!=“无”;
如果(元素填充)
{
element.fillcolor=currentStyle[“fill”]| |“Black”;
}
}
然后将此块添加到页面中,以便将此新行为应用于VML元素:

<style>
    .rvml
    {
        behavior: url(#default#VML) url(vmlcss.htc);
    }
</style>

.rvml
{
行为:url(#default#VML)url(vmlcss.htc);
}

就这些。在运行IEHi Elise时,CSS中指定的笔划颜色和填充颜色现在应应用于VML元素,请在此处检查我的答案:
<style>
    .rvml
    {
        behavior: url(#default#VML) url(vmlcss.htc);
    }
</style>