function loadStyleString(css) {
//加 :before属性
var style = document.createElement("style");
style.type = "text/css";
try {
style.appendChild(document.createTextNode(css));
} catch (ex) {
style.styleSheet.cssText = css;
}
var head = document.getElementsByTagName('head')[0];
head.appendChild(style);
}
使用
loadStyleString(".box:before{content:'前缀';color: red;}");