是否有自动匹配类名称的工具?
如果给出HTML文件和CSS文件
示例:
HTML文件
<div class="a"></div>
CSS文件
.a {
font-size: 12px;
color: blue;
}
生成如:
{
a: {
'font-size': '12px',
'color': 'blue',
}
}
答案 0 :(得分:0)
DIY是一个选择:
appendCss({
"my-class": {
"background": "yellow",
"padding": "10px"
}
});
function appendCss (css) {
var style = document.createElement("style");
style.textContent = cssToString(css);
document.head.appendChild(style);
}
function cssToString (css) {
var c, p, s = "";
for (c in css) {
s += "." + c + "{";
for (p in css[c]) {
s += p + ":" + css[c][p] + ";";
}
s += "}";
}
return s;
}
&#13;
<span class="my-class">merry xmas</span>
&#13;