HTML Element Style How to - Fit picture to screen








Question

We would like to know how to fit picture to screen.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#imgA {<!--   ww w  . j  a v a  2 s .  co m-->
  background-image:url("http://placehold.it/1000x1000");
  background-size: 100%;
  position: fixed;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
}
</style>
</head>
<body>
  <a id="imgA" href='http://www.java2s.com' target='_blank' /a>
</body>
</html>

The code above is rendered as follows: