Answers for "html height whole page"

0

full page height css

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
body {
  height: 100%;
  margin: 0;
}

.full-height {
  height: 100%;
  background: green;
}
</style>

</head>
<body>

<div class="full-height">full page height css</div>

</body>
</html>
Posted by: Guest on March-17-2021
0

how to find total height of single page page in html

function calculateTotalHeightMinusElement(excludeElementClass)
{
  // Get all child elements of the body tag
  var bodyChildren = (document.getElementsByTagName('body')[0]).children;

  var totalHeight = 0;

  // Loop through the selected elements
  for (var i = 0; i < bodyChildren.length; i++) {

    // Add the height of this element
    totalHeight = totalHeight + bodyChildren[i].offsetHeight;
  }

  // Get the height of the element we want to exclude
  var excludedElementHeight = document.getElementsByClassName(excludeElementClass)[0].offsetHeight;

  // Calculate height minus the excluded element
  var finalHeight = totalHeight - excludedElementHeight;

  // Display the final height in an alert
  alert("Total height: " + finalHeight);
}

document.addEventListener("DOMContentLoaded", function(event) {

  // Pass in the class name of the element you want to minus from the height calculation
  calculateTotalHeightMinusElement("myDivClass");
});
Posted by: Guest on February-22-2021
0

full page height css

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
body {
  height: 100%;
  margin: 0;
}

.full-height {
  height: 100%;
  background: green;
}
</style>

</head>
<body>

<div class="full-height">full page height css</div>

</body>
</html>
Posted by: Guest on March-17-2021
0

how to find total height of single page page in html

function calculateTotalHeightMinusElement(excludeElementClass)
{
  // Get all child elements of the body tag
  var bodyChildren = (document.getElementsByTagName('body')[0]).children;

  var totalHeight = 0;

  // Loop through the selected elements
  for (var i = 0; i < bodyChildren.length; i++) {

    // Add the height of this element
    totalHeight = totalHeight + bodyChildren[i].offsetHeight;
  }

  // Get the height of the element we want to exclude
  var excludedElementHeight = document.getElementsByClassName(excludeElementClass)[0].offsetHeight;

  // Calculate height minus the excluded element
  var finalHeight = totalHeight - excludedElementHeight;

  // Display the final height in an alert
  alert("Total height: " + finalHeight);
}

document.addEventListener("DOMContentLoaded", function(event) {

  // Pass in the class name of the element you want to minus from the height calculation
  calculateTotalHeightMinusElement("myDivClass");
});
Posted by: Guest on February-22-2021

Code answers related to "html height whole page"

Browse Popular Code Answers by Language