js 動態(tài)修改css文件的方法
更新時間:2014年08月05日 09:30:03 投稿:whsnow
css文件可以用js 動態(tài)修改,在做一些交互動作時,非常實用,下面是具體示例,大家可以看看
_.find(document.styleSheets[4].cssRules,function(cssRule){
if(cssRule.selectorText && cssRule.selectorText.indexOf(".navbar-fixed-top2")>-1){
cssRule.style.position="";
cssRule.style.top = "0px";
}
if(cssRule.selectorText && cssRule.selectorText.indexOf("#pageIndi_content, #page1_l1_content, #page_appList") >-1){
cssRule.style.padding = "0px";
}
if(cssRule.selectorText && cssRule.selectorText.indexOf("#page1_index_content") >-1){
cssRule.style.padding = "0px";
}
});
循環(huán)用的underscore,在使用cssRule不能直接使用下面的代碼,否則不會生效
cssRule.style=" left: 0;position:'';right: 0; top: 0px;z-index: 1031;";
只能使用
cssRule.style.padding = "0px";
相關(guān)文章
BootStrapTable 單選及取值的實現(xiàn)方法
學(xué)習(xí)bootstrapTable 一直沒有找到 單選框的選定的和取值的教程,接下來通過本文給大家分享BootStrapTable 單選及取值的實現(xiàn)方法,非常不錯,需要的朋友參考下2017-01-01
關(guān)于Object.entries()方法的使用和實現(xiàn)方式
這篇文章主要介紹了關(guān)于Object.entries()方法的使用和實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02

