js調用css屬性寫法_javascript技巧
來源:懂視網
責編:小采
時間:2020-11-27 21:13:43
js調用css屬性寫法_javascript技巧
js調用css屬性寫法_javascript技巧:1、對于沒有中劃線的css屬性一般直接使用style.屬性名即可。 如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、對于含有中劃線的css屬性,將每個中劃線去掉并將每個中劃線后的第一個字符換成大寫即可。 如:obj.st
導讀js調用css屬性寫法_javascript技巧:1、對于沒有中劃線的css屬性一般直接使用style.屬性名即可。 如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、對于含有中劃線的css屬性,將每個中劃線去掉并將每個中劃線后的第一個字符換成大寫即可。 如:obj.st

1、對于沒有中劃線的css屬性一般直接使用style.屬性名即可。
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。
2、對于含有中劃線的css屬性,將每個中劃線去掉并將每個中劃線后的第一個字符換成大寫即可。
如:obj.style.marginTop,obj.style.borderLeftWidth,obj.style.zIndex,obj.style.fontFamily等。
因為float是Javascript的保留字,那怎么在js中書寫樣式表中的float呢?
我們不能直接使用obj.style.float來使用,這樣操作是無效的。
其正確的使用方法是為:IE:obj.style.styleFloat,其他瀏覽器Mozilla(gecko),ff等用styleFloat:obj.style.cssFloat。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
js調用css屬性寫法_javascript技巧
js調用css屬性寫法_javascript技巧:1、對于沒有中劃線的css屬性一般直接使用style.屬性名即可。 如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、對于含有中劃線的css屬性,將每個中劃線去掉并將每個中劃線后的第一個字符換成大寫即可。 如:obj.st