相关疑难解决方法(0)

什么是offsetHeight,clientHeight,scrollHeight?

想解释之间有什么区别的offsetHeight,clientHeightscrollHeightoffsetWidth,clientWidthscrollWidth

在客户端工作之前必须知道这种差异.否则他们的一半生命将用于修复UI.

小提琴或下面的内联:

function whatis(propType) {
  var mainDiv = document.getElementById("MainDIV");
  if (window.sampleDiv == null) {
    var div = document.createElement("div");
    window.sampleDiv = div;
  }
  div = window.sampleDiv;
  var propTypeWidth = propType.toLowerCase() + "Width";
  var propTypeHeight = propType + "Height";

  var computedStyle = window.getComputedStyle(mainDiv, null);
  var borderLeftWidth = computedStyle.getPropertyValue("border-left-width");
  var borderTopWidth = computedStyle.getPropertyValue("border-top-width");

  div.style.position = "absolute";
  div.style.left = mainDiv.offsetLeft + Math.round(parseFloat((propType == "client") ? borderLeftWidth : 0)) + "px"; …
Run Code Online (Sandbox Code Playgroud)

html javascript dom offsetheight

205
推荐指数
4
解决办法
10万
查看次数

标签 统计

dom ×1

html ×1

javascript ×1

offsetheight ×1