【问题标题】:text font-size attr was invalid when invoked paper.setViewBox() on chrome在 chrome 上调用 paper.setViewBox() 时,文本字体大小属性无效
【发布时间】:2013-02-19 14:25:09
【问题描述】:
window.onload = function(){
    var r = Raphael("world", 500, 500);
    r.text(100, 100, "US").attr({
        "font-size": 5
    });
    r.setViewBox(0, 0, 300, 300, false); //remove this line, chrome will work fine.    
}

文本的字体大小为 12px(chrome 默认最小字体大小),而不是 5px。 我添加了关于 *{-webkit-text-size-adjust: none;} 的 css,但它没有用。 该问题出现在 chrome 537.22 版本上

【问题讨论】:

    标签: javascript jquery google-chrome svg raphael


    【解决方案1】:

    .attr() 用于 HTML 属性。为此使用.css()

    r.text(100, 100, "US").css({
            "font-size": 5
        });
    

    【讨论】:

    • .attr() 是 Raphael Element 属性,它不是 jquery 方法。
    猜你喜欢
    • 2013-02-11
    • 2011-01-18
    • 2012-07-02
    • 2018-05-26
    • 1970-01-01
    • 2011-02-28
    • 2020-01-07
    • 2018-08-11
    • 1970-01-01
    相关资源
    最近更新 更多