javascript css styleFloat和cssFloat
更新時(shí)間:2010年03月15日 11:52:02 作者:
在寫(xiě)js操作css的過(guò)程中發(fā)現(xiàn)float屬性在IE和firefox下對(duì)應(yīng)的js腳本是不一樣的,IE下對(duì)應(yīng)得是 styleFloat,firefox,chorme,safari下對(duì)應(yīng)的是cssFloat,可用in運(yùn)算符去檢測(cè)style是否包含此屬性。
下面是兼容性代碼
LTFunction.setFloatStyle=function(obj,style)
{
var sty=obj.style;
if('cssFloat' in sty){
obj.style.cssFloat=style;
}else if('styleFloat' in sty){
obj.style.styleFloat=style;
}else{
throw 'set float style:'+style+'error.';
}
}
復(fù)制代碼 代碼如下:
LTFunction.setFloatStyle=function(obj,style)
{
var sty=obj.style;
if('cssFloat' in sty){
obj.style.cssFloat=style;
}else if('styleFloat' in sty){
obj.style.styleFloat=style;
}else{
throw 'set float style:'+style+'error.';
}
}
您可能感興趣的文章:
- javascript css float屬性的特殊寫(xiě)法
- css 跨瀏覽器實(shí)現(xiàn)float:center
- CSS中Float(浮動(dòng))相關(guān)技巧文章
- javascript下操作css的float屬性的特殊寫(xiě)法
- css position: absolute、relative詳解
- CSS定位中Positoin、absolute、Relative的一些研究
- relative absolute無(wú)法沖破的等級(jí)問(wèn)題解決
- Div CSS absolute與relative的區(qū)別小結(jié)
- position:relative/absolute無(wú)法沖破的等級(jí)
- 解決rs.absolutepage=-1的問(wèn)題
- 詳細(xì)分析css float 屬性以及position:absolute 的區(qū)別
相關(guān)文章
在JavaScript中使用嚴(yán)格模式(Strict Mode)
這篇文章主要介紹了在JavaScript中使用嚴(yán)格模式(Strict Mode),除了正常運(yùn)行模式,ECMAscript 5添加了第二種運(yùn)行模式:"嚴(yán)格模式"(strict mode)。顧名思義,這種模式使得Javascript在更嚴(yán)格的條件下運(yùn)行。,需要的朋友可以參考下2019-06-06
uniapp使用uni.chooseLocation()打開(kāi)地圖選擇位置詳解
這篇文章主要給大家介紹了關(guān)于uniapp使用uni.chooseLocation()打開(kāi)地圖選擇位置的相關(guān)資料,因?yàn)樽罱陧?xiàng)目中遇到一個(gè)要用戶授權(quán)位置且可以用戶自己選擇位置的功能,需要的朋友可以參考下2023-06-06
JavaScript 自定義html元素鼠標(biāo)右鍵菜單功能
這篇文章主要介紹了JavaScript 自定義html元素鼠標(biāo)右鍵菜單功能,本文通過(guò)實(shí)例代碼給大家分享實(shí)現(xiàn)思路,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12
基于Bootstrap的網(wǎng)頁(yè)設(shè)計(jì)實(shí)例
這篇文章主要介紹了基于Bootstrap的網(wǎng)頁(yè)設(shè)計(jì)實(shí)例,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03
JS實(shí)現(xiàn)簡(jiǎn)易的圖片拖拽排序?qū)嵗a
這篇文章主要介紹了JS實(shí)現(xiàn)簡(jiǎn)易的圖片拖拽排序?qū)嵗a,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06

