{"id":8425,"date":"2019-01-26T22:01:09","date_gmt":"2019-01-26T14:01:09","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8425"},"modified":"2019-01-26T22:54:06","modified_gmt":"2019-01-26T14:54:06","slug":"dom-quiz-27-window-scroll","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/01\/dom-quiz-27-window-scroll\/","title":{"rendered":"DOM\u57fa\u7840\u5c0f\u6d4b27\u671f\u7b54\u7591\u6587\u5b57\u7248-\u7a97\u4f53\u6eda\u52a8\u4e8c\u4e09\u4e8b"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8425\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=8425<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4e2a\u4eba\u7f51\u7ad9\u65e0\u9700\u6388\u6743\uff0c\u53ea\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u3001\u51fa\u5904\u4ee5\u53ca\u6587\u4e2d\u94fe\u63a5\u5373\u53ef\uff0c\u4efb\u4f55\u7f51\u7ad9\u5747\u53ef\u6458\u8981\u805a\u5408\uff0c\u5546\u7528\u8bf7\u8054\u7cfb\u6388\u6743\u3002<br \/>\n<script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/201901-quiz.jpg';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201901\/quiz-thumb.jpg\" width=\"484\" height=\"300\" alt=\"\u5c0f\u6d4b\u5934\u56fe\" class=\"alignnone clip size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u9898\u76ee\u4e0e\u8003\u5bdf\u70b9<\/h3>\n<p>\u9898\u76ee\u5982\u4e0b\uff08\u7eb8\u8d28\u6253\u5370\u62cd\u6444\u56fe\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/dom-27-quiz.jpg\" width=\"572\" height=\"397\" alt=\"DOM\u5c0f\u6d4b\u9898\u76ee\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u662f\u76f8\u5f53\u7b80\u5355\u7684\u4e00\u9053\u9898\u76ee\uff0c\u5165\u95e8\u7ea7\u522b\u7684\uff0c\u867d\u7136\u633a\u7b80\u5355\uff0c\u4f46\u8fd8\u6709\u5f88\u591a\u7ec6\u8282\u662f\u5f88\u591a\u4eba\u4e0d\u77e5\u9053\u7684\uff0c\u56e0\u6b64\u8fd8\u662f\u5f88\u6709\u4ef7\u503c\u7684\u3002<\/p>\n<p>\u672c\u9898\u4e3b\u8981\u8003\u5bdf\u7a97\u4f53\u6eda\u52a8\uff0c\u7a97\u4f53\u9ad8\u5ea6\u83b7\u53d6\uff0c\u666e\u901a\u5143\u7d20\u9ad8\u5ea6\u83b7\u53d6\u8fd9\u51e0\u4e2a\u77e5\u8bc6\u70b9\u3002<\/p>\n<p>\u672c\u6b21B\u7ad9\u76f4\u64ad\u5728\u4e0a\u5348\u670810:15\u5206\u5f00\u59cb\uff0c\u6301\u7eed\u7ea640\u5206\u949f\uff0c\u6709\u5f55\u64ad\uff0c\u53ef\u4ee5\u76f4\u63a5\u4e0b\u9762\u6d4f\u89c8\u3002<\/p>\n<p><iframe loading=\"lazy\" id=\"biliIframe\" src=\"\/\/player.bilibili.com\/player.html?aid=41743974&#038;cid=73292527&#038;page=1\" scrolling=\"no\" border=\"0\" frameborder=\"no\" framespacing=\"0\" allowfullscreen=\"true\" width=\"100%\" height=\"546\"><\/iframe><\/p>\n<p><script>if (screen.width < 640) { document.getElementById('biliIframe').style.height = '60vw'; }<\/script><\/p>\n<h3>\u4e8c\u3001\u7b54\u7591\u5185\u5bb9<\/h3>\n<p>\u5927\u5bb6\u56de\u7b54\u5730\u5740\u8fd9\u91cc\uff1a<a href=\"https:\/\/github.com\/zhangxinxu\/quiz\/issues\/4\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/zhangxinxu\/quiz\/issues\/4<\/a><\/p>\n<h4>1. \u5173\u4e8e\u8282\u6d41\u51fd\u6570<\/h4>\n<p>\u6709\u4e0d\u5c11\u4eba\u7b54\u9898\u65f6\u5019\u4f7f\u7528\u4e86\u8282\u6d41\u51fd\u6570\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>function Throttle(fn, delay) {\r\n  let last = 0,\r\n  timer = null;\r\n  return function() {\r\n    let context = this,\r\n    args = arguments,\r\n    now = +new Date();\r\n    if (now - last < delay) {\r\n      clearTimeout(timer)\r\n      timer = setTimeout(function() {\r\n         last = now;\r\n         fn.apply(context, args);\r\n      }, delay)\r\n    } else {\r\n      last = now;\r\n     fn.apply(context, args);\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u4ee3\u7801\u9ad8\u4eae\u7248\u672c\u89c1\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/2019-01-26_205602.png\" width=\"259\" height=\"336\" alt=\"\u8282\u6d41\u51fd\u6570\u4ee3\u7801\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u521d\u8877\u662f\u597d\u7684\uff0c\u6eda\u52a8\u662f\u4e00\u4e2a\u9ad8\u9891\u89e6\u53d1\u7684\u64cd\u4f5c\uff0c\u901a\u8fc7\u8282\u6d41\u51fd\u6570\u53ef\u4ee5\u964d\u4f4e\u8ba1\u7b97\u65b9\u6cd5\u6267\u884c\u7684\u9891\u7387\u3002\u4f46\u662f\uff0c\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5f00\u53d1\u7684\u5927\u591a\u6570\u9875\u9762\u662f\u5982\u6b64\u7684\u7b80\u5355\uff0c\u6839\u672c\u7528\u4e0d\u5230\u9700\u8981\u8282\u6d41\u51fd\u6570\uff0c\u53cd\u800c\u589e\u52a0\u4e86\u4ee3\u7801\u7684\u590d\u6742\u5ea6\uff0c\u5bf9\u4e8e\u672c\u9898\uff0c\u53ef\u4ee5\u4e0d\u9700\u8981\u3002<\/p>\n<h4>2. \u7a97\u4f53\u6eda\u52a8\u4e8b\u4ef6\u7ed1\u5728\u54ea\u91cc\uff1f<\/h4>\n<p>\u6d4f\u89c8\u5668\u7a97\u4f53\u6eda\u52a8\u4e8b\u4ef6\u7ed1\u5728\u54ea\u4e2a\u5bf9\u8c61\u4e0a\u5462\uff1f\u662f<code>window<\/code>\u5bf9\u8c61\uff0c\u8fd8\u662f<code>document<\/code>\u5bf9\u8c61\uff0c\u6216\u8005\u662f<code>document.documentElement<\/code>\uff0c<code>document.body<\/code>\uff1f<\/p>\n<p>\u6211\u4eec\u4e0d\u59a8\u6d4b\u8bd5\u4e0b\uff1a<\/p>\n<pre>window.addEventListener('scroll', function () {\r\n    console.log('window\u6eda\u52a8\u89e6\u53d1\uff0cwindow.pageYOffset\u662f\uff1a' + this.pageYOffset);\r\n});\r\ndocument.addEventListener('scroll', function () {\r\n    console.log('document\u6eda\u52a8\u89e6\u53d1\uff0cdocument.scrollTop\u662f\uff1a' + this.scrollTop);\r\n});\r\ndocument.documentElement.addEventListener('scroll', function () {\r\n    console.log('document.documentElement\u6eda\u52a8\u89e6\u53d1\uff0cdocument.documentElement.scrollTop\u662f\uff1a' + this.scrollTop);\r\n});\r\ndocument.body.addEventListener('scroll', function () {\r\n    console.log('document.body\u6eda\u52a8\u89e6\u53d1\uff0cdocument.body.scrollTop\u662f\uff1a' + this.scrollTop);\r\n});<\/pre>\n<p>\u60a8\u53ef\u4ee5\u8bc6\u522b\u6b64\u4e8c\u7ef4\u7801\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/qr-scroll.png\" width=\"150\" height=\"150\" alt=\"\u4e8c\u7ef4\u7801\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6216\u8005\u76f4\u63a5\u70b9\u51fb\u8fd9\u4e2a\u9875\u9762\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201901\/scroll.html\" rel=\"noopener\" target=\"_blank\">\u89e6\u53d1scroll\u4e8b\u4ef6\u7684\u6eda\u52a8\u5bb9\u5668\u6d4b\u8bd5demo<\/a><\/p>\n<p>\u7ed3\u679c\u65e0\u8bba\u662fPC\uff0c\u8fd8\u662f\u79fb\u52a8\u7aef\uff0c\u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/Screenshot_20190126_211407.png\" width=\"400\" height=\"660\" alt=\"\u6eda\u52a8\u6d4b\u8bd5\u7ed3\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e5f\u5c31\u662f<code>window<\/code>\u5bf9\u8c61\u548c<code>document<\/code>\u5bf9\u8c61\u7ed1\u5b9ascroll\u4e8b\u4ef6\u53ef\u4ee5\u89e6\u53d1\uff0c<code>document.documentElement<\/code>\u548c<code>document.body<\/code>\u662f\u4e0d\u884c\u7684\u3002<\/p>\n<p>\u7136\u540e\uff0c\u76f4\u64ad\u7684\u65f6\u5019\u6709\u4eba\u5728\u7fa4\u91cc\u53cd\u9988\uff0c\u81ea\u5df1\u7684\u624b\u673a<code>document<\/code>\u6eda\u52a8\u65e0\u6cd5\u89e6\u53d1\uff0c\u5982\u679c\u8fd9\u662f\u771f\u7684\uff0c\u90a3\u5b89\u5168\u8d77\u89c1\uff0c\u9ed8\u8ba4\u7684\u6d4f\u89c8\u5668\u7a97\u4f53\u6eda\u52a8\u4e8b\u4ef6\u8fd8\u662f\u7ed1\u5b9a\u5728<code>window<\/code>\u5bf9\u8c61\u4e0a\u3002<\/p>\n<h4>3. \u7a97\u4f53\u7684\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6<\/h4>\n<p>\u5982\u4f55\u83b7\u53d6\u7a97\u4f53\u7684\u6eda\u52a8\u9ad8\u5ea6\u5462\uff1f\u5e38\u89c1\u7684\u6709\u4e0b\u97623\u79cd\u4ee3\u7801\uff1a<\/p>\n<pre>window.pageYOffset;\r\ndocument.documentElement.scrollTop;\r\ndocument.body.scrollTop;<\/pre>\n<p>\u90fd\u662f\u6709\u6548\u7684\u5417\uff1f<\/p>\n<p>\u6211\u4eec\u4e0d\u59a8\u6d4b\u8bd5\u4e0b\uff0c\u60f3\u529e\u6cd5\u8bc6\u522b\u6b64\u4e8c\u7ef4\u7801\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/qr-scrolltop.png\" width=\"150\" height=\"150\" alt=\"\u6eda\u52a8\u9ad8\u5ea6\u4e8c\u7ef4\u7801\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6216\u8005\u76f4\u63a5\u8bbf\u95ee\u8fd9\u4e2a\u9875\u9762\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201901\/scrolltop.html\" rel=\"noopener\" target=\"_blank\">3\u79cd\u7a97\u4f53\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\u65b9\u6cd5\u6d4b\u8bd5demo<\/a><\/p>\n<p>\u7ed3\u679c\u5728PC\u4e0a\u662f\u8fd9\u6837\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/2019-01-26_212308.png\" width=\"274\" height=\"362\" alt=\"PC\u4e0a\u6eda\u52a8\u9ad8\u5ea6\u8bc6\u522b\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u800c\u5728\u624b\u673a\u4e0a\u5219\u662f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/Screenshot_20190126_212636.png\" width=\"400\" height=\"618\" alt=\"\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\u79fb\u52a8\u7aef\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u684c\u9762\u6d4f\u89c8\u5668\u548c\u79fb\u52a8\u7aef\u6d4f\u89c8\u5668\u5bf9\u4e8e\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\u662f\u6709\u5dee\u522b\u7684\uff0c\u684c\u9762\u7aef\u6d4f\u89c8\u5668\u4e0d\u80fd\u4f7f\u7528<code>document.body.scrollTop<\/code>\u83b7\u53d6\u6d4f\u89c8\u5668\u7a97\u4f53\u7684\u6eda\u52a8\u9ad8\u5ea6\uff0c\u800c\u79fb\u52a8\u7aef\u4e0d\u80fd\u4f7f\u7528<code>document.documentElement.scrollTop<\/code>\u83b7\u53d6\u6d4f\u89c8\u5668\u7a97\u4f53\u7684\u6eda\u52a8\u9ad8\u5ea6\u3002\u4f46\u662f\u90fd\u652f\u6301<code>window.pageYOffset<\/code>\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u7406\u8bba\u4e0a\u8bb2\uff0c\u6d4f\u89c8\u5668\u7a97\u4f53\u7684\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\u4f7f\u7528<code>window.pageYOffset<\/code>\u5373\u53ef\uff0c\u7136\u800c<code>window.pageYOffset<\/code>\u6709\u4e00\u4e2a\u7f3a\u70b9\uff0c\u5c31\u662fIE9\u53ca\u5176\u4ee5\u4e0a\u6d4f\u89c8\u5668\u624d\u652f\u6301\uff0c\u5728PC\u7aef\uff0c\u5f88\u591a\u9879\u76ee\u662f\u9700\u8981\u517c\u5bb9IE8\u6d4f\u89c8\u5668\u7684\uff0c\u56e0\u6b64\uff0c\u5bf9\u4e8e\u4f20\u7edfPC\u7f51\u7ad9\uff0c\u83b7\u53d6\u6d4f\u89c8\u5668\u7a97\u4f53\u6eda\u52a8\u9ad8\u5ea6\u6bd4\u8f83\u597d\u7684\u8868\u8fbe\u65b9\u6cd5\u662f\u8fd9\u6837\uff1a<\/p>\n<pre>var winScrollTop = window.pageYOffset || document.documentElement.scrollTop;<\/pre>\n<h4>3. \u6d4f\u89c8\u5668\u7a97\u4f53\u9ad8\u5ea6\u83b7\u53d6<\/h4>\n<p>\u8fd9\u4e2a\u53ef\u4ee5\u4f7f\u7528<code>window.innerHeight<\/code>\u83b7\u53d6\u3002\u7136\u800c\uff0c<code>window.innerHeight<\/code>\u6709\u517c\u5bb9\u6027\u95ee\u9898\uff0cIE8\u6d4f\u89c8\u5668\u53ca\u5176\u4ee5\u4e0b\u6d4f\u89c8\u5668\u662f\u4e0d\u652f\u6301\u7684\uff0c\u600e\u4e48\u529e\uff1f\u53ef\u4ee5\u501f\u52a9<code>document.documentElement.clientHeight<\/code>\u83b7\u53d6\u3002<\/p>\n<p>\u4e8e\u662f\uff1a<br \/>\npre>var winHeight = window.innerHeight || document.documentElement.clientHeight;<\/p>\n<p><code>document.documentElement<\/code>\u662f\u4e2a\u5f88\u7279\u6b8a\u7684\u5bf9\u8c61\uff0c\u4ed6\u7684\u5f88\u591a\u884c\u4e3a\u8868\u73b0\u8ddf\u666e\u901a\u5143\u7d20\u662f\u4e0d\u4e00\u6837\u7684\u3002\u4f8b\u5982\uff0c\u666e\u901adiv\u8fd9\u7c7b\u5143\u7d20\u7684<code>clientHeight<\/code>\u662f\u4e0d\u5305\u62ec\u8fb9\u6846\u5927\u5c0f\u7684\uff0c\u4f46\u662f\uff0c<code>document.documentElement.clientHeight<\/code>\u76f4\u63a5\u65e0\u89c6\u8fd9\u4e9b\uff0c\u65e0\u8bba\u4f60<code>&lt;html&gt;<\/code>\u5143\u7d20\u662f\u5426\u8bbe\u7f6e\u4e86<code>border<\/code>\uff0c\u90fd\u662f\u9875\u9762\u53ef\u89c6\u533a\u57df\u7684\u9ad8\u5ea6\u3002\u66f4\u795e\u5947\u7684\u662f<code>document.documentElement.offsetHeight<\/code>\u5c45\u7136\u662f\u5305\u542b\u6d4f\u89c8\u5668\u6eda\u52a8\u9ad8\u5ea6\u7684\u5b8c\u6574\u9ad8\u5ea6\uff0c\u7b49\u540c\u4e8e<code>document.documentElement.scrollHeight<\/code>\uff0c\u5927\u5bb6\u53ef\u4ee5\u7279\u6b8a\u8bb0\u5fc6\u4e0b\u3002<\/p>\n<h4>4. \u666e\u901a\u5143\u7d20\u7684\u6eda\u52a8\u548c\u9ad8\u5ea6\u83b7\u53d6<\/h4>\n<p>\u666e\u901a\u5143\u7d20\u7684\u6eda\u52a8\u76f4\u63a5\u6dfb\u52a0scroll\u4e8b\u4ef6\u5c31\u597d\u4e86\uff0c\u6ca1\u6709\u4efb\u4f55\u517c\u5bb9\u6027\u5dee\u5f02\u3002<\/p>\n<pre>dom.addEventListener('scroll', function () {\r\n    console.log('\u5143\u7d20\u6eda\u52a8\u89e6\u53d1\uff0c\u6eda\u52a8\u9ad8\u5ea6\u662f\uff1a' + this.scrollTop);\r\n});<\/pre>\n<p>\u9ad8\u5ea6\u83b7\u53d6\u5219\u4f7f\u7528<code>clientHeight<\/code>\uff0c\u56e0\u4e3a\u6eda\u52a8\u7684\u5185\u5bb9\u662f\u4e0d\u5305\u62ec<code>border-box<\/code>\u7684\uff1a<\/p>\n<pre>dom.addEventListener('scroll', function () {\r\n    if (this.scrollTop > this.clientHeight) {\r\n        console.log('\u6eda\u52a8\u8d85\u8fc7\u4e00\u5c4f\u4e86');\r\n    }\r\n});<\/pre>\n<p>\u5bf9\u4e8e\u666e\u901a\u5143\u7d20\u7684\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\uff0c\u8fd8\u6709\u5f88\u591a\u5176\u4ed6\u7684\u539f\u751fAPI\uff0c\u4f8b\u5982<code>offsetHeight<\/code>\uff0c\u5305\u542b<code>border<\/code>\u8fb9\u6846\u5927\u5c0f\uff1b<code>scrollHeight<\/code>\u5305\u62ec\u6eda\u52a8\u9ad8\u5ea6\uff1bgetBoundingClientRect().height\u4e5f\u662f\u9ad8\u5ea6\u83b7\u53d6\uff0c\u4e0d\u4f1a\u53ef\u4ee5\u662f\u5c0f\u6570\uff0c\u7279\u6b8a\u573a\u666f\u633a\u6709\u7528\u7684\u3002<\/p>\n<h3>\u4e09\u3001\u7b54\u9898\u6838\u5fc3\u6982\u8981\u603b\u7ed3<\/h3>\n<ol>\n<li>\u7a97\u4f53\u6eda\u52a8\u4f7f\u7528window.addEventListener\uff0cdocument\u6709\u4eba\u53cd\u9988\u4e0d\u53cd\u5e94\uff1b<\/li>\n<li>\u7a97\u4f53\u6eda\u52a8\u6eda\u52a8\u9ad8\u5ea6\u83b7\u53d6\uff1awindow.pageYoffset(IE9+)\uff0c<br \/>\n    document.documentElement.scrollTop(PC)\uff0cdocument.body.scrollTop(Mobile)\uff1b<\/li>\n<li>\u666e\u901a\u5143\u7d20\u76f4\u63a5scrollTop\uff1b<\/li>\n<li>\u7a97\u4f53\u9ad8\u5ea6\u83b7\u53d6\uff1awindow.innerHeight(IE9+)\uff0c<br \/>\n    \u5907\u9009\u65b9\u6cd5\u4e3a\uff1adocument.documentElement.clientHeight\uff1b<\/li>\n<li>\u666e\u901a\u5143\u7d20\u9ad8\u5ea6\u83b7\u53d6\uff1a\u672c\u9898\u6eda\u52a8\u4e8b\u4ef6\u4e2d\u4f7f\u7528clientHeight\uff08\u4e0d\u542b\u8fb9\u6846\uff0c\u6eda\u52a8\u662f\u5728border-box\u91cc\u9762\u7684\uff09\uff0c<br \/>\n    offsetHeight\u5305\u542b\u8fb9\u6846\uff0c\u4f46\u662f\u662f\u6574\u6570\uff1b<br \/>\n    getBoundingClientRect().height\u4e5f\u5305\u542b\u8fb9\u6846\uff0c\u53ef\u662f\u662f\u5c0f\u6570\u3002\uff08\u6240\u6709\u8fd9\u51e0\u4e2a\u9ad8\u5ea6\u76f8\u5173API\u90fd\u517c\u5bb9IE6+\uff09<\/li>\n<\/ol>\n<p><strong>\u91cd\u8981\u53c2\u8003\u6587\u6863<\/strong><\/p>\n<p>\u672c\u6587\u63d0\u5230\u7684pageYoffset\uff0cinnerHeight\uff0cclientHeight\uff0coffsetHeight\uff0cgetBoundingClientRect\u7b49\u539f\u751fAPI\u90fd\u5c5e\u4e8eCSSOM\u89c6\u56fe\u6a21\u5f0f(CSSOM View Module)\u76f8\u5173\u5185\u5bb9\uff0c\u672c\u6587\u8fd9\u91cc\u53ea\u662f\u4e00\u90e8\u5206\uff0c\u66f4\u591a\u5185\u5bb9\u53ef\u4ee5\u53c2\u89c1\u672c\u7ad9\u7ecf\u5178\u6587\u7ae0\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=1907\">CSSOM\u89c6\u56fe\u6a21\u5f0f(CSSOM View Module)\u76f8\u5173\u6574\u7406<\/a>\u201d\u3002<\/p>\n<p><strong>\u4e0b\u6b21\u76f4\u64ad\u9884\u544a<\/strong><\/p>\n<p>\u4e0b\u5468\u4e09\u7fa4\u91cc\u53d1\u5e03CSS\u5c0f\u6d4b\u7b2c2\u671f\u6b63\u5e38\uff0c\u4f46\u662f\u7531\u4e8e\u5468\u516d\u4e0a\u73ed\uff0c\u6709\u6070\u9022\u6625\u8282\uff0c\u56e0\u6b64\u76f4\u64ad\u7b54\u7591\u63a8\u8fdf\u5230\u5e74\u540e\u3002\u60f3\u52a0\u5165\u6211\u7684\u7c89\u4e1d\u7fa4\u7684\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1\u597d\u53cb zhangxinxu-job\uff0c\u6211\u62c9\u4f60\u4eec\u8fdb\u53bb\uff0c\u5907\u6ce8\u201c\u5165\u7fa4\u201d\uff0c\u7136\u540e\u9644\u4e0a\u4f60\u4eec\u7684\u59d3\u540d\uff0c\u65b9\u4fbf\u6211\u5907\u6ce8\u3002<\/p>\n<p>\u6700\u540e\uff0c\u795d\u5e7f\u5927\u5b66\u53cb\u65b0\u5e74\u5feb\u4e50\uff0c\u9022\u80f8\u5316\u5409\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/2019-01-26_141405.jpg\" width=\"150\" height=\"77\" alt=\"\u4e8c\u4e43\u7684\u80f8\u90e8\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8425\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=8425<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201901\/quiz-thumb.jpg\" width=\"161\" height=\"100\" alt=\"\u5c0f\u6d4b\u5934\u56fe\" lazyload=\"on\" class=\"alignright size-medium\"><\/p>\n<p>\u672c\u6b21\u5c0f\u6d4b\u501f\u4e00\u4e2a\u7b80\u5355\u6848\u4f8b\u8ddf\u5927\u5bb6\u8bb2\u8bb2CSSOM\u89c6\u56fe\u6a21\u5f0f\uff08CSSOM View Module\uff09\u76f8\u5173\u7684\u4e00\u4e9bAPI\u53ca\u5176\u7279\u6027\uff0c\u9002\u7528\u573a\u666f\u7b49\uff0c\u603b\u7ed3\u51fa\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\uff0c\u660e\u786e\u4e00\u4e9b\u6280\u672f\u7ec6\u8282\uff0c\u8ba9\u6280\u672f\u66f4\u52a0\u7cbe\u7eaf\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1284],"tags":[628,182,790,623,1402,631,1401,1403,633,525,1400],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/8425"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=8425"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/8425\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=8425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=8425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=8425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}