代码之家  ›  专栏  ›  技术社区  ›  Ivan-Mark Debono

ExCSS中的StyleRules属性怎么了?

  •  0
  • Ivan-Mark Debono  · 技术社区  · 6 年前

    var parser = new Parser();
    var sheet = parser.Parse(css);
    var query = from rule in sheet.StyleRules select rule;
    

    我已升级到最新版本(v3.0.0),并将上述内容更改为:

    var parser = new StylesheetParser();
    var sheet = parser.Parse(css);
    var query = from rule in sheet.StyleRules select rule;
    

    StyleRules

    1 回复  |  直到 6 年前
        1
  •  0
  •   Luke Woodward    6 年前

    readme.md ExCSS GitHub repository ,现在叫 Rules

    var parser = new StylesheetParser();
    var stylesheet = parser.Parse(".someClass{color: red; background-image: url('/images/logo.png')");     
    
    var rule = stylesheet.Rules.First();
    var selector = rule.SelectorText; // Yields .someClass
        var color = rule.Style.Color;
    var image = rule.Style.BackgroundImage; // url('/images/logo.png')