CSS Layout How to - Set Top of Element 100px From Bottom of Window








Question

We would like to know how to set Top of Element 100px From Bottom of Window.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.a {<!--from w  w  w. j ava2s  . c  o  m-->
  width: 100px;
  height: 90px;
  background: red;
  margin-bottom: -100%;
}

.b {
  position: absolute;
  bottom: 100px;
}
</style>
</head>
<body>
  <div class='b'>
    <div class='a'>element</div>
  </div>
</body>
</html>

The code above is rendered as follows: