欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

document.compatMode的CSS1compat使用介紹

 更新時(shí)間:2014年04月03日 09:16:50   作者:  
這篇文章主要介紹了document.compatMode的CSS1compat使用,需要的朋友可以參考下
document.compatMode

BackCompat:標(biāo)準(zhǔn)兼容模式關(guān)閉。瀏覽器寬度:document.body.clientWidth;

CSS1Compat:標(biāo)準(zhǔn)兼容模式開啟。 瀏覽器寬度:document.documentElement.clientWidth。
復(fù)制代碼 代碼如下:

var d = document,
  dd = d.documentElement,
  db = d.body,
  dc = d.compatMode == 'CSS1Compat',
  dx = dc ? dd: db;

cWidth = dx.clientWidth;

cHeight = dx.clientHeight;

sWidth = dx.scrollWidth;

sHeight = dx.scrollHeight;

sLeft = dx.scrollLeft;

sTop = dx.scrollTop;


在Standars mode中:

元素真正的寬度 = margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right;

在Quirks mode中:

width則是元素的實(shí)際寬度,內(nèi)容寬度 = width - (margin-left + margin-right + padding-left + padding-right + border-left-width + border-right-width)

在js中如何判斷當(dāng)前瀏覽器正在以何種方式解析?
document對(duì)象有個(gè)屬性compatMode ,它有兩個(gè)值:

BackCompat 對(duì)應(yīng)quirks mode
CSS1Compat 對(duì)應(yīng)strict mode


瀏覽器的兼容性表

http://www.quirksmode.org/compatibility.html

歷史原因:

當(dāng)早期的瀏覽器Netscape 4和Explorer 4對(duì)css進(jìn)行解析時(shí),并未遵守W3C標(biāo)準(zhǔn),這時(shí)的解析方式就被我們稱之為quirks mode(怪異模式),但隨著W3C的標(biāo)準(zhǔn)越來越重要,眾多的瀏覽器開始依照W3C標(biāo)準(zhǔn)解析CSS,仿照W3C標(biāo)準(zhǔn)解析CSS的模式我們叫做strict mode(嚴(yán)格模式)
firefly

相關(guān)文章

最新評(píng)論