我有以下javascript代码:

$(document).ready(function() {
    var paper = new Raphael(document.getElementById('canvas_container'), 1000, 1000);
    var tetronimo = paper.path("M 700 700 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z");
    tetronimo.attr({
        gradient: '90-#526c7a-#64a0c1',
        stroke: '#3b4449',
        'stroke-width': 10,
        'stroke-linejoin': 'round',
        rotation: -90
    });
});


HTML在这里:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>Raphael Test</title>
        <script type="text/javascript" src="js/libs/jquery.js"></script>
        <script type="text/javascript" src="js/libs/raphael.js"></script>
        <script type="text/javascript" src="js/test.js"></script>
        <link href="css/screen.css" rel="stylesheet" />
    </head>
    <body>
        <div id="canvas_container"></div>
    </body>
</html>


它在许多浏览器上都能很好地工作,但是渐变背景在IE7和IE8上不起作用。有什么解决方案?

最佳答案

我根据documentation page弄清楚了。无需使用gradient属性(某些旧版本的库),而需要使用fill属性,它可以工作!

var tetronimo = paper.path("M 700 700 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z");
tetronimo.attr({
    fill: '90-#526c7a-#64a0c1',
    'fill-opacity': 0.5,
    stroke: '#3b4449',
    'stroke-width': 10,
    'stroke-linejoin': 'round',
    rotation: -90
});

关于javascript - 路径对象的Raphael渐变背景在IE8和IE7上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14209415/

10-11 05:44