javascript css styleFloat和cssFloat
更新時間:2010年03月15日 11:52:02 作者:
在寫js操作css的過程中發(fā)現(xiàn)float屬性在IE和firefox下對應(yīng)的js腳本是不一樣的,IE下對應(yīng)得是 styleFloat,firefox,chorme,safari下對應(yīng)的是cssFloat,可用in運(yùn)算符去檢測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屬性的特殊寫法
- css 跨瀏覽器實(shí)現(xiàn)float:center
- CSS中Float(浮動)相關(guān)技巧文章
- javascript下操作css的float屬性的特殊寫法
- css position: absolute、relative詳解
- CSS定位中Positoin、absolute、Relative的一些研究
- relative absolute無法沖破的等級問題解決
- Div CSS absolute與relative的區(qū)別小結(jié)
- position:relative/absolute無法沖破的等級
- 解決rs.absolutepage=-1的問題
- 詳細(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()打開地圖選擇位置詳解
這篇文章主要給大家介紹了關(guān)于uniapp使用uni.chooseLocation()打開地圖選擇位置的相關(guān)資料,因?yàn)樽罱陧?xiàng)目中遇到一個要用戶授權(quán)位置且可以用戶自己選擇位置的功能,需要的朋友可以參考下2023-06-06
JavaScript 自定義html元素鼠標(biāo)右鍵菜單功能
這篇文章主要介紹了JavaScript 自定義html元素鼠標(biāo)右鍵菜單功能,本文通過實(shí)例代碼給大家分享實(shí)現(xiàn)思路,非常不錯,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12
基于Bootstrap的網(wǎng)頁設(shè)計(jì)實(shí)例
這篇文章主要介紹了基于Bootstrap的網(wǎng)頁設(shè)計(jì)實(shí)例,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03
JS實(shí)現(xiàn)簡易的圖片拖拽排序?qū)嵗a
這篇文章主要介紹了JS實(shí)現(xiàn)簡易的圖片拖拽排序?qū)嵗a,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-06-06

