Skip to content

Instantly share code, notes, and snippets.

@HaoweiCh
Last active October 8, 2023 00:59
Show Gist options
  • Save HaoweiCh/11288df3f21710dcae372824d97a31a8 to your computer and use it in GitHub Desktop.
Save HaoweiCh/11288df3f21710dcae372824d97a31a8 to your computer and use it in GitHub Desktop.
在 DOM 插入CSS样式
function addCssFile(url) {
var link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", url);
document.head.appendChild(link);
}
function addCssStyle(css) {
document.head.appendChild(document.createElement("style")).textContent = css;
}
(function(){
var signCSS = "";
signCSS += "#desc img{max-width:1000px;height:auto}";
/*
signCSS += "#headTd{border-bottom:1px solid grey; color:blue; padding:0px 0px 5px 0px !important;}";
signCSS += "#footTd{border-top:1px solid grey; color:blue; padding:6px 0px 0px 0px !important;}";
signCSS += ".signbaInfor{white-space:nowrap; padding:0px 6px 0px 6px;}";
signCSS += "#scrollDiv *{font-size:12px !important; line-height:18px !important;} #scrollDiv{max-height:" + (maxLines * 18) + "px; max-width:1200px;}";
signCSS += "#newbutn,#newbutn2,#newbutn3,#zhidaoDiv{float:right;}#useIdDiv,#thDiv{float:left;}";
signCSS += "#timerDiv{z-index:997; position:fixed;left:5px;top:5px;}";
signCSS += "#getDown,#allsign,#newbutn,#newbutn2,#newbutn3{background:rgba(228,228,228,0.4); cursor:pointer; margin:0px 1px 0px 0px; padding:0px 3px;color:black; border:2px ridge black;}";
signCSS += "#getDown:active,#allsign:active,#newbutn:active,#newbutn3:active{border:2px groove black;}";
signCSS += "#readyDiv,#messageWindow{z-index:9999; padding:6px 10px 8px 10px;background-color:lightGrey; position:fixed;right:5px;bottom:5px;border:1px solid grey}";
*/
addCssStyle(signCSS);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment