开发者

Is there a way to get all valid keywords for CSS property?

Round two. First was "How do I get all supported CSS properties in WebKit?".

开发者_开发问答

I'm looking for magic CSSkeywords function:

CSSkeywords('float') --> ['left', 'right', 'none']
CSSkeywords('width') --> ['auto']
CSSkeywords('background') --> [
  ["repeat", "repeat-x", "repeat-y", "no-repeat"], 
  ["scroll", "fixed"], 
  ["top", "center", "bottom", "left"],
  /*regexp for color*/,
  /*regexp for url*/,
  "none"
]


You're going to have to write that yourself.


A duplicate of this question was posted, which I answered with the following. Posting it here in case that other question gets deleted.


No, I don't think there's anywhere in the standard browser environment (such as it is!) accessible with JavaScript that lists all of the possible values of CSS properties. (Not even for those properties that do have a constrained set of possible values.)

This information is covered by various specifications, though, the CSS 2010 snapshot covers the main body of it (the list of properties is particularly useful for what you're describing). The CSS Basic User Interface Level 3 CR also has a lot of stuff (box-sizing, for instance), and there are several further proposals covered in various additional CRs and LCs [and even WDs] on the W3C website.

Those are primary sources. (I prefer to cite primary sources.) There seems to be a pretty good secondary source here, without (as of this writing) massive adverts, and with links per property to both primary (W3C) and useful secondary (MDN) sites.


There are some code that you could take a look for instance open source browser codebase and some of them are using real great autocomplete algorithms that you could base your work on.

https://github.com/chromium/chromium/tree/master/third_party/blink/renderer/core/css

Here is an example of the Animation Priority properties from chromnium:

https://github.com/chromium/chromium/blob/master/third_party/blink/renderer/core/css/css_properties.json5#L548-L553

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜