CSS Property Value How to - background-size: cover; Background color over top of background image








Question

We would like to know how to background-size: cover; Background color over top of background image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--from   ww  w .  j ava2 s  .  c  om-->
  background: red url("http://www.java2s.com/style/download.png") center top no-repeat
    fixed;
  background-size: cover;
}

#content {
  background: #fff;
  margin: 20px auto;
  padding: 10px 15px;
  width: 80%;
}
</style>
</head>
<body>
  <!-- Head and body should be here -->
  <div id="content">
    <p>My content, articles images and stuff</p>
  </div>
  <!-- body closing tag should be here -->
</body>
</html>

The code above is rendered as follows: