css-parsing

Do custom CSS properties use one leading dash or two?

半世苍凉 提交于 2019-11-28 02:04:29
#elem { -myCustom: 99; } OR #elem { --myCustom: 99; } I have seen both of the above used in examples online. What the difference between the two? Trying to access custom properties in JavaScript returns null.. #elem { -myCustom: 99; } <div id="elem">some text</div> elem = document.getElementById("elem"); style= window.getComputedStyle(elem); value = style.getPropertyValue('-myCustom'); alert(value); single leading dash is used for vendor prefixes double leading dash is used for defining custom properties . 2 Defining Custom Properties: the '--*' family of properties A custom property is any

Parsing CSS by regex

℡╲_俬逩灬. 提交于 2019-11-26 09:01:20
问题 I\'m creating a CSS editor and am trying to create a regular expression that can get data from a CSS document. This regex works if I have one property but I can\'t get it to work for all properties. I\'m using preg/perl syntax in PHP. Regex (?<selector>[A-Za-z]+[\\s]*)[\\s]*{[\\s]*((?<properties>[A-Za-z0-9-_]+)[\\s]*:[\\s]*(?<values>[A-Za-z0-9#, ]+);[\\s]*)*[\\s]*} Test case body { background: #f00; font: 12px Arial; } Expected Outcome Array( [0] => Array( [0] => body { background: #f00; font