Page Widget How to - Keep background image centered








Question

We would like to know how to keep background image centered.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--from w w  w . j a v  a  2 s. c  o  m-->
  background: url('http://www.java2s.com/style/download.png');
  background-position: center 0%;
  background-repeat: no-repeat;
}
</style>
</head>
<body>
</body>
</html>

The code above is rendered as follows: